Skip to content

Commit

Permalink
fix(st-storage): turn STStorageOutput fields into optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro committed Apr 22, 2024
1 parent a898414 commit b6fbdc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions antarest/study/business/areas/st_storage_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def to_config(self, study_version: t.Union[str, int]) -> STStorageConfigType:


@camel_case_model
class STStorageOutput(STStorage880Config):
class STStorageOutput(STStorage880Config, metaclass=AllOptionalMetaclass, use_none=True):
"""
Model representing the form used to display the details of a short-term storage entry.
"""
Expand Down Expand Up @@ -236,7 +236,7 @@ def create_storage_output(
cluster_id: str,
config: t.Mapping[str, t.Any],
) -> "STStorageOutput":
obj = create_st_storage_config(study_version, **config, id=cluster_id)
obj = create_st_storage_config(study_version=study_version, **config, id=cluster_id)
kwargs = obj.dict(by_alias=False)
return STStorageOutput(**kwargs)

Expand Down Expand Up @@ -357,11 +357,12 @@ def get_all_storages_props(
except KeyError:
raise STStorageConfigNotFound(path) from None

study_version = study.version
storages_by_areas: t.MutableMapping[str, t.MutableMapping[str, STStorageOutput]]
storages_by_areas = collections.defaultdict(dict)
for area_id, cluster_obj in storages.items():
for cluster_id, cluster in cluster_obj.items():
storages_by_areas[area_id][cluster_id] = create_storage_output(int(study.version), cluster_id, cluster)
storages_by_areas[area_id][cluster_id] = create_storage_output(study_version, cluster_id, cluster)

return storages_by_areas

Expand Down
5 changes: 5 additions & 0 deletions tests/integration/study_data_blueprint/test_table_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ def test_lifecycle__nominal(
"id",
"name",
# Short-term storage fields
"enabled", # since v8.8
"group",
"injectionNominalCapacity",
"withdrawalNominalCapacity",
Expand Down Expand Up @@ -670,6 +671,7 @@ def test_lifecycle__nominal(
# "id": "siemens",
# "name": "Siemens",
"efficiency": 1,
"enabled": None,
"group": "Battery",
"initialLevel": 0.5,
"initialLevelOptim": False,
Expand All @@ -681,6 +683,7 @@ def test_lifecycle__nominal(
# "id": "tesla",
# "name": "Tesla",
"efficiency": 0.75,
"enabled": None,
"group": "Battery",
"initialLevel": 0.89,
"initialLevelOptim": False,
Expand All @@ -692,6 +695,7 @@ def test_lifecycle__nominal(
# "id": "storage3",
# "name": "storage3",
"efficiency": 1,
"enabled": None,
"group": "Pondage",
"initialLevel": 1,
"initialLevelOptim": False,
Expand All @@ -703,6 +707,7 @@ def test_lifecycle__nominal(
# "id": "storage4",
# "name": "storage4",
"efficiency": 1,
"enabled": None,
"group": "PSP_open",
"initialLevel": 0.5,
"initialLevelOptim": True,
Expand Down

0 comments on commit b6fbdc3

Please sign in to comment.