From 450b2a2167cad9b8613e94476cd23f85b5a2097c Mon Sep 17 00:00:00 2001 From: Sigurd Borge Date: Tue, 10 Sep 2024 11:43:49 +0200 Subject: [PATCH] Added create local binding constraint --- .../local_services/binding_constraint_local.py | 7 ++++++- tests/antares/services/local_services/test_study.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/antares/service/local_services/binding_constraint_local.py b/src/antares/service/local_services/binding_constraint_local.py index 0647942c..15254e03 100644 --- a/src/antares/service/local_services/binding_constraint_local.py +++ b/src/antares/service/local_services/binding_constraint_local.py @@ -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 diff --git a/tests/antares/services/local_services/test_study.py b/tests/antares/services/local_services/test_study.py index 5280c9b2..d786599d 100644 --- a/tests/antares/services/local_services/test_study.py +++ b/tests/antares/services/local_services/test_study.py @@ -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 ( @@ -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)