Skip to content

Commit

Permalink
Added create local binding constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigurd-Borge committed Sep 10, 2024
1 parent 75e9870 commit 450b2a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def create_binding_constraint(
equal_term_matrix: Optional[pd.DataFrame] = None,
greater_term_matrix: Optional[pd.DataFrame] = None,
) -> BindingConstraint:
raise NotImplementedError
return BindingConstraint(
name=name,
binding_constraint_service=self,
properties=properties,
terms=terms,
)

def add_constraint_terms(self, constraint: BindingConstraint, terms: List[ConstraintTerm]) -> List[ConstraintTerm]:
raise NotImplementedError
Expand Down
11 changes: 11 additions & 0 deletions tests/antares/services/local_services/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from antares.config.local_configuration import LocalConfiguration
from antares.exceptions.exceptions import CustomError, LinkCreationError
from antares.model.area import AreaProperties, AreaUi, AreaUiLocal, AreaPropertiesLocal, Area
from antares.model.binding_constraint import BindingConstraint
from antares.model.commons import FilterOption
from antares.model.hydro import Hydro
from antares.model.link import (
Expand Down Expand Up @@ -1058,3 +1059,13 @@ def test_created_link_with_custom_ui_values(self, tmp_path, local_study_w_areas)
assert actual_ini_string == expected_ini_string
assert actual_properties == LinkPropertiesLocal(expected_properties).yield_link_properties()
assert actual_ui == LinkUiLocal(expected_ui).yield_link_ui()


class TestCreateBindingconstraint:
def test_can_be_created(self, local_study_with_hydro):
# When
binding_constraint_name = "test constraint"
binding_constraint = local_study_with_hydro.create_binding_constraint(name=binding_constraint_name)

# Then
assert isinstance(binding_constraint, BindingConstraint)

0 comments on commit 450b2a2

Please sign in to comment.