Skip to content

Commit

Permalink
Merge branch 'dev' into fix/enforce-sqlite-foreign-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvlecl authored Oct 7, 2024
2 parents 63f8790 + d120a68 commit 7d269e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion antarest/study/business/allocation_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def get_allocation_matrix(self, study: Study, all_areas: List[AreaInfoDTO]) -> A
"""

file_study = self.storage_service.get_storage(study).get_raw(study)
allocation_cfg = file_study.tree.get("input/hydro/allocation/*".split("/"), depth=2)
allocation_cfg = file_study.tree.get(["input", "hydro", "allocation"], depth=3)

if not allocation_cfg:
areas_ids = {area.id for area in all_areas}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ def clear_all_snapshots(self, retention_hours: timedelta, params: t.Optional[Req
snapshot_clearing_task_instance,
task_name,
task_type=TaskType.SNAPSHOT_CLEARING,
ref_id="SNAPSHOT_CLEANING",
ref_id=None,
custom_event_messages=None,
request_params=params,
)
Expand Down
14 changes: 10 additions & 4 deletions tests/integration/study_data_blueprint/test_hydro_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ def test_get_allocation_matrix(
area_id: str,
expected: t.List[t.List[float]],
) -> None:
client.headers = {"Authorization": f"Bearer {user_access_token}"}
"""Check `get_allocation_matrix` end point"""
res = client.get(
f"/v1/studies/{internal_study_id}/areas/hydro/allocation/matrix",
headers={"Authorization": f"Bearer {user_access_token}"},
)
res = client.get(f"/v1/studies/{internal_study_id}/areas/hydro/allocation/matrix")
assert res.status_code == http.HTTPStatus.OK, res.json()
actual = res.json()
assert actual == expected

# test get allocation matrix with a study with only one area.
client.delete(f"/v1/studies/{internal_study_id}/areas/de")
client.delete(f"/v1/studies/{internal_study_id}/areas/es")
client.delete(f"/v1/studies/{internal_study_id}/areas/fr")
res = client.get(f"/v1/studies/{internal_study_id}/areas/hydro/allocation/matrix")
assert res.status_code == http.HTTPStatus.OK, res.json()
assert res.json() == {"index": ["it"], "columns": ["it"], "data": [[1.0]]}

def test_set_allocation_form_values(
self,
client: TestClient,
Expand Down

0 comments on commit 7d269e9

Please sign in to comment.