diff --git a/antarest/study/business/binding_constraint_management.py b/antarest/study/business/binding_constraint_management.py index a382277bd5..ac012ed0e0 100644 --- a/antarest/study/business/binding_constraint_management.py +++ b/antarest/study/business/binding_constraint_management.py @@ -423,6 +423,7 @@ def constraint_model_adapter(constraint: Mapping[str, Any], version: int) -> Con "terms": constraint.get("terms", []), } + # TODO: Implement a model for version-specific fields. Output filters are sent regardless of the version. if version >= 840: constraint_output["filter_year_by_year"] = constraint.get("filter_year_by_year") or constraint.get( "filter-year-by-year", "" diff --git a/antarest/study/storage/variantstudy/model/command/create_binding_constraint.py b/antarest/study/storage/variantstudy/model/command/create_binding_constraint.py index 5a832b7d29..8d666db596 100644 --- a/antarest/study/storage/variantstudy/model/command/create_binding_constraint.py +++ b/antarest/study/storage/variantstudy/model/command/create_binding_constraint.py @@ -75,13 +75,13 @@ class BindingConstraintProperties(BaseModel, extra=Extra.forbid, allow_populatio enabled: bool = True time_step: BindingConstraintFrequency = BindingConstraintFrequency.HOURLY operator: BindingConstraintOperator = BindingConstraintOperator.EQUAL - comments: t.Optional[str] = None - filter_year_by_year: t.Optional[str] = None - filter_synthesis: t.Optional[str] = None + comments: t.Optional[str] = "" + filter_year_by_year: t.Optional[str] = "" + filter_synthesis: t.Optional[str] = "" class BindingConstraintProperties870(BindingConstraintProperties): - group: t.Optional[str] = None + group: t.Optional[str] = "default" class BindingConstraintMatrices(BaseModel, extra=Extra.forbid, allow_population_by_field_name=True): diff --git a/tests/variantstudy/model/command/test_manage_binding_constraints.py b/tests/variantstudy/model/command/test_manage_binding_constraints.py index aab13307b1..fc124bdb40 100644 --- a/tests/variantstudy/model/command/test_manage_binding_constraints.py +++ b/tests/variantstudy/model/command/test_manage_binding_constraints.py @@ -92,6 +92,7 @@ def test_manage_binding_constraint(empty_study: FileStudy, command_context: Comm "name": "BD 2", "id": "bd 2", "enabled": False, + "comments": "", "area1.cluster": 50.0, "operator": "both", "type": "daily", @@ -127,6 +128,7 @@ def test_manage_binding_constraint(empty_study: FileStudy, command_context: Comm "id": "bd 1", "enabled": False, "area1%area2": "800.0%30", + "comments": "", "operator": "both", "type": "weekly", } @@ -151,6 +153,7 @@ def test_manage_binding_constraint(empty_study: FileStudy, command_context: Comm "id": "bd 2", "enabled": False, "area1.cluster": 50.0, + "comments": "", "operator": "both", "type": "daily", } @@ -338,7 +341,7 @@ def test_revert(command_context: CommandContext): operator=BindingConstraintOperator.EQUAL, coeffs={"a": [0.3]}, values=hourly_matrix_id, - comments=None, + comments="", command_context=command_context, ) ]