Skip to content

Commit

Permalink
Can add constraint terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigurd-Borge committed Sep 13, 2024
1 parent 39b07af commit a0c914f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/antares/services/local_services/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
BindingConstraintProperties,
BindingConstraintFrequency,
BindingConstraintOperator,
ConstraintTerm,
)
from antares.model.commons import FilterOption
from antares.model.hydro import Hydro
Expand Down Expand Up @@ -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()

0 comments on commit a0c914f

Please sign in to comment.