Skip to content

Commit

Permalink
test: remove dto cases
Browse files Browse the repository at this point in the history
Remove all_energy_usage_models and consumer system v2 DTOCases. Replace
with YamlCase and use YamlModel to setup the model.
  • Loading branch information
jsolaas committed Oct 24, 2024
1 parent 7cbf9db commit 400374d
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 900 deletions.
2 changes: 0 additions & 2 deletions src/libecalc/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .case_types import DTOCase, YamlCase
from .cases.all_energy_usage_models import * # noqa: F403
from .cases.consumer_system_v2 import (
consumer_system_v2_dto,
consumer_system_v2_dto_fixture,
consumer_system_v2_yaml,
)
from .cases.consumer_with_time_slots_models import * # noqa: F403
Expand Down
13 changes: 13 additions & 0 deletions src/libecalc/fixtures/case_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
from pathlib import Path
from typing import Dict, NamedTuple, TextIO

from ecalc_cli.infrastructure.file_resource_service import FileResourceService
from libecalc.common.time_utils import Frequency
from libecalc.common.variables import VariablesMap
from libecalc.dto import Asset
from libecalc.presentation.yaml.file_configuration_service import FileConfigurationService
from libecalc.presentation.yaml.model import YamlModel
from libecalc.presentation.yaml.yaml_entities import MemoryResource


Expand All @@ -19,6 +23,15 @@ def main_file(self) -> TextIO:
lines = f.read()
return io.StringIO(lines)

def get_yaml_model(self, frequency: Frequency = Frequency.NONE) -> YamlModel:
configuration_service = FileConfigurationService(self.main_file_path)
resource_service = FileResourceService(self.main_file_path.parent)
return YamlModel(
configuration_service=configuration_service,
resource_service=resource_service,
output_frequency=frequency,
)


class DTOCase(NamedTuple):
ecalc_model: Asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from libecalc.fixtures.case_utils import YamlCaseLoader

from .all_models_dto import (
all_energy_usage_models_dto,
compressor,
compressor_system,
compressor_system_variable_speed_compressor_trains,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1110,103 +1110,6 @@ def genset_sampled() -> GeneratorSetSampled:
)


@pytest.fixture
def all_energy_usage_models_dto(
regularity,
fuel_gas,
genset_sampled,
generic_from_design_point_compressor_train_consumer,
simplified_variable_speed_compressor_train_known_stages_consumer,
simplified_variable_speed_compressor_train_unknown_stages_consumer,
deh,
late_start_consumer,
late_start_consumer_evolving_type,
salt_water_injection_tabular,
water_injection_single_speed,
water_injection_variable_speed,
pump_system_el_consumer,
simplified_compressor_system,
simplified_compressor_train_predefined_variable_speed_charts_with_gerg_fluid,
variable_speed_compressor_train_predefined_charts,
single_speed_compressor_train_asv_pressure_control,
single_speed_compressor_train_upstream_choke_pressure_control,
single_speed_compressor_train_downstream_choke_pressure_control,
single_speed_compressor_train_downstream_choke_pressure_control_maximum_discharge_pressure,
variable_speed_compressor_train_multiple_input_streams_and_interstage_pressure,
compressor,
tabulated,
compressor_system,
turbine_driven_compressor_train,
compressor_system_variable_speed_compressor_trains,
methane_venting,
flare,
all_energy_usage_models_variables,
) -> DTOCase:
return DTOCase(
Asset(
name="all_energy_usage_models",
installations=[
Installation(
user_defined_category=InstallationUserDefinedCategoryType.FIXED,
name="MAIN_INSTALLATION",
regularity=regularity,
hydrocarbon_export={
Period(datetime(1900, 1, 1), datetime(2021, 1, 1)): Expression.setup_from_expression(
value="SIM1;OIL_PROD {+} SIM1;GAS_PROD {/} 1000"
),
},
fuel_consumers=[
GeneratorSet(
name="GeneratorSet",
user_defined_category={
Period(
datetime(1900, 1, 1), datetime(2021, 1, 1)
): ConsumerUserDefinedCategoryType.TURBINE_GENERATOR
},
generator_set_model={
Period(datetime(1900, 1, 1), datetime(2018, 1, 1)): genset_sampled,
Period(datetime(2018, 1, 1), datetime(2021, 1, 1)): genset_sampled,
},
regularity=regularity,
fuel=fuel_gas,
consumers=[
generic_from_design_point_compressor_train_consumer,
simplified_variable_speed_compressor_train_known_stages_consumer,
simplified_variable_speed_compressor_train_unknown_stages_consumer,
deh,
late_start_consumer,
late_start_consumer_evolving_type,
salt_water_injection_tabular,
water_injection_single_speed,
water_injection_variable_speed,
pump_system_el_consumer,
simplified_compressor_system,
simplified_compressor_train_predefined_variable_speed_charts_with_gerg_fluid,
variable_speed_compressor_train_predefined_charts,
single_speed_compressor_train_asv_pressure_control,
single_speed_compressor_train_upstream_choke_pressure_control,
single_speed_compressor_train_downstream_choke_pressure_control,
single_speed_compressor_train_downstream_choke_pressure_control_maximum_discharge_pressure,
variable_speed_compressor_train_multiple_input_streams_and_interstage_pressure,
],
),
flare,
compressor,
tabulated,
compressor_system,
turbine_driven_compressor_train,
compressor_system_variable_speed_compressor_trains,
],
venting_emitters=[
methane_venting,
],
)
],
),
all_energy_usage_models_variables,
)


@pytest.fixture
def compressor_systems_and_compressor_train_temporal_dto(
regularity,
Expand Down
4 changes: 0 additions & 4 deletions src/libecalc/fixtures/cases/consumer_system_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

from libecalc.fixtures import YamlCase
from libecalc.fixtures.case_utils import YamlCaseLoader
from libecalc.fixtures.cases.consumer_system_v2.consumer_system_v2_dto import (
consumer_system_v2_dto,
consumer_system_v2_dto_fixture,
)

"""
Test project for Consumer System v2
Expand Down
Loading

0 comments on commit 400374d

Please sign in to comment.