Skip to content

Commit

Permalink
resolve first comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jan 16, 2025
1 parent b21b816 commit ed5616a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ def create_binding_constraint(
def duplicate_binding_constraint(
uuid: str,
binding_constraint_id: str,
new_name: str,
new_constraint_name: str,
current_user: JWTUser = Depends(auth.get_current_user),
) -> ConstraintOutput:
logger.info(
Expand All @@ -1358,7 +1358,7 @@ def duplicate_binding_constraint(
params = RequestParameters(user=current_user)
study = study_service.check_study_access(uuid, StudyPermissionType.WRITE, params)
return study_service.binding_constraint_manager.duplicate_binding_constraint(
study, binding_constraint_id, new_name
study, binding_constraint_id, new_constraint_name
)

@bp.delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,9 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st

# Duplicates the constraint
duplicated_name = "BC_4"
res = client.post(f"/v1/studies/{study_id}/bindingconstraints/{bc_id}", params={"new_name": duplicated_name})
res = client.post(
f"/v1/studies/{study_id}/bindingconstraints/{bc_id}", params={"new_constraint_name": duplicated_name}
)
res.raise_for_status()
duplicated_constraint = res.json()

Expand All @@ -502,13 +504,15 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st

# Asserts duplication fails if given an non-exisiting constraint
fake_name = "fake_name"
res = client.post(f"/v1/studies/{study_id}/bindingconstraints/{fake_name}", params={"new_name": "aa"})
res = client.post(
f"/v1/studies/{study_id}/bindingconstraints/{fake_name}", params={"new_constraint_name": "aa"}
)
assert res.status_code == 404
assert res.json()["exception"] == "BindingConstraintNotFound"
assert res.json()["description"] == f"Binding constraint '{fake_name}' not found"

# Asserts duplication fails if given an already existing name
res = client.post(f"/v1/studies/{study_id}/bindingconstraints/{bc_id}", params={"new_name": bc_id})
res = client.post(f"/v1/studies/{study_id}/bindingconstraints/{bc_id}", params={"new_constraint_name": bc_id})
assert res.status_code == 409
assert res.json()["exception"] == "DuplicateConstraintName"
assert res.json()["description"] == f"A binding constraint with the same name already exists: {bc_id}."
Expand Down Expand Up @@ -991,7 +995,8 @@ def test_for_version_870(self, client: TestClient, user_access_token: str, study
# Duplicates the constraint
duplicated_name = "BC_4"
res = client.post(
f"/v1/studies/{study_id}/bindingconstraints/{bc_id_w_matrix}", params={"new_name": duplicated_name}
f"/v1/studies/{study_id}/bindingconstraints/{bc_id_w_matrix}",
params={"new_constraint_name": duplicated_name},
)
res.raise_for_status()
duplicated_constraint = res.json()
Expand Down

0 comments on commit ed5616a

Please sign in to comment.