Skip to content

Commit

Permalink
test(bc): use terms in constraints tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Mar 28, 2024
1 parent e899d00 commit ae23954
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions tests/integration/study_data_blueprint/test_binding_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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": [[]],
Expand All @@ -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": [[]],
},
Expand All @@ -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(),
}
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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": [[]],
},
Expand Down Expand Up @@ -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": "",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]},
},
}
],
Expand All @@ -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": {},
},
}
],
Expand Down

0 comments on commit ae23954

Please sign in to comment.