Skip to content

Commit

Permalink
feat(api): adding read_study method, unit testing and integration tes…
Browse files Browse the repository at this point in the history
…ting of the method
  • Loading branch information
mehdiwahada committed Dec 4, 2024
1 parent f6f1a61 commit e140264
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 59 deletions.
57 changes: 4 additions & 53 deletions tests/antares/services/api_services/test_study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,55 +216,6 @@ def test_read_study_api(self):
}
}

json_thermal = [
{
"id": "therm_un",
"group": "Gas",
"name": "therm_un",
"enabled": "true",
"unitCount": 1,
"nominalCapacity": 0,
}
]

json_renewable = [
{
"id": "test_renouvelable",
"group": "Solar Thermal",
"name": "test_renouvelable",
"enabled": "true",
"unitCount": 1,
"nominalCapacity": 0,
"tsInterpretation": "power-generation",
}
]

json_st_storage = [
{
"id": "test_storage",
"group": "Pondage",
"name": "test_storage",
"injectionNominalCapacity": 0,
"withdrawalNominalCapacity": 0,
"reservoirCapacity": 0,
"efficiency": 1,
"initialLevel": 0.5,
"initialLevelOptim": "false",
"enabled": "true",
}
]

json_properties = {
"energyCostUnsupplied": 0,
"energyCostSpilled": 0,
"nonDispatchPower": "true",
"dispatchHydroPower": "true",
"otherDispatchPower": "true",
"filterSynthesis": ["weekly", "daily", "hourly", "monthly", "annual"],
"filterByYear": ["weekly", "daily", "hourly", "monthly", "annual"],
"adequacyPatchMode": "outside",
}

config_urls = re.compile(f"https://antares.com/api/v1/studies/{self.study_id}/config/.*")

base_url = "https://antares.com/api/v1"
Expand All @@ -279,10 +230,10 @@ def test_read_study_api(self):
mocker.get(url, json=json_study)
mocker.get(config_urls, json={})
mocker.get(area_url, json=json_ui)
mocker.get(area_props_url, json=json_properties)
mocker.get(renewable_url, json=json_renewable)
mocker.get(thermal_url, json=json_thermal)
mocker.get(storage_url, json=json_st_storage)
mocker.get(area_props_url, json={})
mocker.get(renewable_url, json=[])
mocker.get(thermal_url, json=[])
mocker.get(storage_url, json=[])
actual_study = read_study_api(self.api, self.study_id)

expected_study_name = json_study.pop("name")
Expand Down
15 changes: 9 additions & 6 deletions tests/integration/test_web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,20 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop):
assert study.name == actual_study.name
assert study.version == actual_study.version
assert list(study.get_areas().keys()) == list(actual_study.get_areas().keys())

expected_area_fr = study.get_areas()["fr"]
actual_area_fr = actual_study.get_areas()["fr"]
assert (
list(expected_area_fr.get_thermals()) == list(actual_area_fr.get_thermals())
)
assert (
study.get_areas()["fr"].get_thermals().get("cluster_test").id
== actual_study.get_areas()["fr"].get_thermals().get("cluster_test").id
list(expected_area_fr.get_renewables()) == list(actual_area_fr.get_renewables())
)
assert (
study.get_areas()["fr"].get_renewables().get("cluster_test").id
== actual_study.get_areas()["fr"].get_renewables().get("cluster_test").id
list(expected_area_fr.get_st_storages()) == list(actual_area_fr.get_st_storages())
)
assert (
study.get_areas()["fr"].get_st_storages().get("cluster_test").id
== actual_study.get_areas()["fr"].get_st_storages().get("cluster_test").id
list(study.get_settings()) == list(actual_study.get_settings())
)

# test short term storage creation with properties
Expand Down

0 comments on commit e140264

Please sign in to comment.