From ae23954571f1474cffdf83c012761696aed1827c Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Thu, 28 Mar 2024 09:58:32 +0100 Subject: [PATCH] test(bc): use `terms` in constraints tests --- .../test_binding_constraints.py | 38 +++++++++---------- tests/integration/test_integration.py | 4 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/integration/study_data_blueprint/test_binding_constraints.py b/tests/integration/study_data_blueprint/test_binding_constraints.py index 69cc5ac0d2..5d6e596e68 100644 --- a/tests/integration/study_data_blueprint/test_binding_constraints.py +++ b/tests/integration/study_data_blueprint/test_binding_constraints.py @@ -35,7 +35,7 @@ def test_constraint_id(self, area: str, cluster: str, expected: str) -> None: class TestConstraintTerm: - def test_constraint_id__link(self): + def test_constraint_id__link(self) -> bool: term = ConstraintTerm( id="foo", weight=3.14, @@ -204,7 +204,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "New API", }, headers=user_headers, @@ -222,7 +222,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st expected = [ { "comments": "", - "constraints": [], # should be renamed to `terms` in the future. + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -233,7 +233,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st }, { "comments": "", - "constraints": [], # should be renamed to `terms` in the future. + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -244,7 +244,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st }, { "comments": "New API", - "constraints": [], # should be renamed to `terms` in the future. + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -301,7 +301,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st ) assert res.status_code == 200, res.json() binding_constraint = res.json() - constraint_terms = binding_constraint["constraints"] # should be renamed to `terms` in the future. + constraint_terms = binding_constraint["terms"] expected = [ { "data": {"area1": area1_id, "area2": area2_id}, @@ -336,7 +336,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st ) assert res.status_code == 200, res.json() binding_constraint = res.json() - constraint_terms = binding_constraint["constraints"] # should be renamed to `terms` in the future. + constraint_terms = binding_constraint["terms"] expected = [ { "data": {"area1": area1_id, "area2": area2_id}, @@ -426,7 +426,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st # Check that the matrix is a daily/weekly matrix res = client.get( f"/v1/studies/{study_id}/raw", - params={"path": f"input/bindingconstraints/{bc_id}", "depth": 1, "formatted": True}, + params={"path": f"input/bindingconstraints/{bc_id}", "depth": 1, "formatted": True}, #type: ignore headers=user_headers, ) assert res.status_code == 200, res.json() @@ -446,7 +446,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "New API", }, headers=user_headers, @@ -465,7 +465,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "New API", }, headers=user_headers, @@ -484,7 +484,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "", }, headers=user_headers, @@ -499,7 +499,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "2 types of matrices", "values": [[]], "less_term_matrix": [[]], @@ -521,7 +521,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "Incoherent matrix with version", "less_term_matrix": [[]], }, @@ -538,7 +538,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st "enabled": True, "timeStep": "daily", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "Creation with matrix", "values": wrong_matrix.tolist(), } @@ -616,7 +616,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud # Creation of a bc without group bc_id_wo_group = "binding_constraint_1" - args = {"enabled": True, "timeStep": "hourly", "operator": "less", "coeffs": {}, "comments": "New API"} + args = {"enabled": True, "timeStep": "hourly", "operator": "less", "terms": {}, "comments": "New API"} res = client.post( f"/v1/studies/{study_id}/bindingconstraints", json={"name": bc_id_wo_group, **args}, @@ -657,7 +657,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud for term in ["lt", "gt", "eq"]: res = client.get( f"/v1/studies/{study_id}/raw", - params={"path": f"input/bindingconstraints/{bc_id_w_matrix}_{term}", "depth": 1, "formatted": True}, + params={"path": f"input/bindingconstraints/{bc_id_w_matrix}_{term}", "depth": 1, "formatted": True}, #type: ignore headers=admin_headers, ) assert res.status_code == 200 @@ -729,7 +729,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud "path": f"input/bindingconstraints/{bc_id_w_matrix}_{term_alias}", "depth": 1, "formatted": True, - }, + }, # type: ignore headers=admin_headers, ) assert res.status_code == 200 @@ -759,7 +759,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud "enabled": True, "timeStep": "hourly", "operator": "less", - "coeffs": {}, + "terms": {}, "comments": "New API", "values": [[]], }, @@ -932,7 +932,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud assert groups["Group 2"] == [ { "comments": "New API", - "constraints": [], + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index c99b8c9e0e..55607108cb 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -523,7 +523,7 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: "enabled": True, "time_step": BindingConstraintFrequency.HOURLY.value, "operator": BindingConstraintOperator.LESS.value, - "coeffs": {"area 1.cluster 1": [2.0, 4]}, + "terms": {"area 1.cluster 1": [2.0, 4]}, }, } ], @@ -541,7 +541,7 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: "enabled": True, "time_step": BindingConstraintFrequency.HOURLY.value, "operator": BindingConstraintOperator.LESS.value, - "coeffs": {}, + "terms": {}, }, } ],