diff --git a/src/antares/service/local_services/binding_constraint_local.py b/src/antares/service/local_services/binding_constraint_local.py index 15254e03..e2402ec3 100644 --- a/src/antares/service/local_services/binding_constraint_local.py +++ b/src/antares/service/local_services/binding_constraint_local.py @@ -35,7 +35,8 @@ def create_binding_constraint( ) def add_constraint_terms(self, constraint: BindingConstraint, terms: List[ConstraintTerm]) -> List[ConstraintTerm]: - raise NotImplementedError + new_terms = [term for term in terms if term.id not in constraint.get_terms()] + return new_terms def delete_binding_constraint_term(self, constraint_id: str, term_id: str) -> None: raise NotImplementedError diff --git a/tests/antares/services/local_services/test_study.py b/tests/antares/services/local_services/test_study.py index ef4fd2e5..bcb4839f 100644 --- a/tests/antares/services/local_services/test_study.py +++ b/tests/antares/services/local_services/test_study.py @@ -14,6 +14,7 @@ BindingConstraintProperties, BindingConstraintFrequency, BindingConstraintOperator, + ConstraintTerm, ) from antares.model.commons import FilterOption from antares.model.hydro import Hydro @@ -1167,3 +1168,8 @@ def test_constraints_and_ini_have_custom_properties(self, local_study_with_const # Then assert actual_ini_content == expected_ini_content + + def test_constraint_can_add_term(self, test_constraint): + new_term = [ConstraintTerm(data={"area1": "fr", "area2": "at"})] + test_constraint.add_terms(new_term) + assert test_constraint.get_terms()