Skip to content

Commit

Permalink
test(thermal): add parameterized test for v8.6 and v8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jan 4, 2024
1 parent 83a7674 commit 151765a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ def create_thermal_cluster(
- `cluster_data`: the properties used for creation:
"name" and "group".
Returns: The properties of the newly-created thermal clusters.
Returns: The properties of the newly-created thermal cluster.
"""
logger.info(
f"Creating thermal cluster for study '{uuid}' and area '{area_id}'",
Expand Down
33 changes: 17 additions & 16 deletions tests/integration/study_data_blueprint/test_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@

from antarest.core.utils.string import to_camel_case
from antarest.study.storage.rawstudy.model.filesystem.config.model import transform_name_to_id
from antarest.study.storage.rawstudy.model.filesystem.config.thermal import Thermal860Properties, ThermalProperties
from antarest.study.storage.rawstudy.model.filesystem.config.thermal import ThermalProperties
from tests.integration.utils import wait_task_completion

DEFAULT_PROPERTIES = json.loads(ThermalProperties(name="Dummy").json())
DEFAULT_PROPERTIES = {to_camel_case(k): v for k, v in DEFAULT_PROPERTIES.items() if k != "name"}

DEFAULT_860_PROPERTIES = json.loads(Thermal860Properties(name="Dummy").json())
DEFAULT_860_PROPERTIES = {to_camel_case(k): v for k, v in DEFAULT_860_PROPERTIES.items() if k != "name"}

# noinspection SpellCheckingInspection
EXISTING_CLUSTERS = [
{
Expand Down Expand Up @@ -267,11 +264,7 @@

@pytest.mark.parametrize(
"version",
[
# pytest.param(0, id="No Upgrade"),
# pytest.param(860, id="v8.6"),
pytest.param(870, id="v8.7")
],
[pytest.param(0, id="No Upgrade"), pytest.param(860, id="v8.6"), pytest.param(870, id="v8.7")],
)
@pytest.mark.unit_test
class TestThermal:
Expand Down Expand Up @@ -303,8 +296,13 @@ def test_lifecycle(
pollutants_values = 0.0 if version >= 860 else None
for existing_cluster in EXISTING_CLUSTERS:
existing_cluster.update({p: pollutants_values for p in pollutants_names})
if version == 870:
existing_cluster.update({"costgeneration": "SetManually", "efficiency": 100.0, "variableomcost": 0.0})
existing_cluster.update(
{
"costgeneration": "SetManually" if version == 870 else None,
"efficiency": 100.0 if version == 870 else None,
"variableomcost": 0.0 if version == 870 else None,
}
)

# =============================
# THERMAL CLUSTER CREATION
Expand Down Expand Up @@ -356,11 +354,14 @@ def test_lifecycle(
"id": fr_gas_conventional_id,
**{p: pollutants_values for p in pollutants_names},
}
if version == 870:
fr_gas_conventional_cfg = {
**fr_gas_conventional_cfg,
**{"costgeneration": "SetManually", "efficiency": 100.0, "variableomcost": 0.0},
}
fr_gas_conventional_cfg = {
**fr_gas_conventional_cfg,
**{
"costgeneration": "SetManually" if version == 870 else None,
"efficiency": 100.0 if version == 870 else None,
"variableomcost": 0.0 if version == 870 else None,
},
}
assert res.json() == fr_gas_conventional_cfg

# reading the properties of a thermal cluster
Expand Down

0 comments on commit 151765a

Please sign in to comment.