From 17dc5ef8379cec2d323441362daa4e25f2541ea4 Mon Sep 17 00:00:00 2001 From: Theo Pascoli Date: Mon, 6 Jan 2025 10:09:53 +0100 Subject: [PATCH 1/3] fix: add comment attribute that was missing and causing an 422 error --- antarest/study/business/model/link_model.py | 2 ++ tests/integration/study_data_blueprint/test_link.py | 6 ++++++ tests/integration/study_data_blueprint/test_table_mode.py | 5 +++++ tests/integration/test_integration.py | 1 + tests/storage/business/test_arealink_manager.py | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/antarest/study/business/model/link_model.py b/antarest/study/business/model/link_model.py index 07398dc88d..f8c8e32ffd 100644 --- a/antarest/study/business/model/link_model.py +++ b/antarest/study/business/model/link_model.py @@ -148,6 +148,7 @@ class LinkBaseDTO(AntaresBaseModel): transmission_capacities: TransmissionCapacity = TransmissionCapacity.ENABLED asset_type: AssetType = AssetType.AC display_comments: bool = True + comments: str = "" colorr: int = Field(default=DEFAULT_COLOR, ge=0, le=255) colorb: int = Field(default=DEFAULT_COLOR, ge=0, le=255) colorg: int = Field(default=DEFAULT_COLOR, ge=0, le=255) @@ -196,6 +197,7 @@ class LinkInternal(AntaresBaseModel): transmission_capacities: TransmissionCapacity = TransmissionCapacity.ENABLED asset_type: AssetType = AssetType.AC display_comments: bool = True + comments: str = "" colorr: int = Field(default=DEFAULT_COLOR, ge=0, le=255) colorb: int = Field(default=DEFAULT_COLOR, ge=0, le=255) colorg: int = Field(default=DEFAULT_COLOR, ge=0, le=255) diff --git a/tests/integration/study_data_blueprint/test_link.py b/tests/integration/study_data_blueprint/test_link.py index 8cf04d58f8..28b8f3da2a 100644 --- a/tests/integration/study_data_blueprint/test_link.py +++ b/tests/integration/study_data_blueprint/test_link.py @@ -44,6 +44,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ "colorg": 112, "colorr": 150, "displayComments": True, + "comments": "", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": True, @@ -83,6 +84,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ "colorg": 112, "colorr": 150, "displayComments": True, + "comments": "", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, @@ -166,6 +168,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type: "colorg": 112, "colorr": 112, "displayComments": True, + "comments": "", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, @@ -189,6 +192,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type: "colorg": 170, "colorr": 180, "displayComments": True, + "comments": "", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, @@ -299,6 +303,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type: "colorg": 112, "colorr": 112, "displayComments": True, + "comments": "", "filterSynthesis": "", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, @@ -327,6 +332,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type: "colorg": 112, "colorr": 112, "displayComments": True, + "comments": "", "filterSynthesis": "hourly", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, diff --git a/tests/integration/study_data_blueprint/test_table_mode.py b/tests/integration/study_data_blueprint/test_table_mode.py index 17133f63be..80159f7a37 100644 --- a/tests/integration/study_data_blueprint/test_table_mode.py +++ b/tests/integration/study_data_blueprint/test_table_mode.py @@ -195,6 +195,7 @@ def test_lifecycle__nominal( "colorg", "colorr", "displayComments", + "comments", "filterSynthesis", "filterYearByYear", "hurdlesCost", @@ -247,6 +248,7 @@ def test_lifecycle__nominal( "colorg": 150, "colorr": 200, "displayComments": False, + "comments": "", "hurdlesCost": True, "linkStyle": "plain", "linkWidth": 2, @@ -262,6 +264,7 @@ def test_lifecycle__nominal( "colorg": 112, "colorb": 112, "displayComments": True, + "comments": "", "hurdlesCost": False, "linkStyle": "plain", "linkWidth": 1, @@ -277,6 +280,7 @@ def test_lifecycle__nominal( "colorg": 150, "colorr": 200, "displayComments": True, + "comments": "", "hurdlesCost": True, "linkStyle": "plain", "linkWidth": 1, @@ -292,6 +296,7 @@ def test_lifecycle__nominal( "colorg": 112, "colorr": 112, "displayComments": True, + "comments": "", "hurdlesCost": True, "linkStyle": "plain", "linkWidth": 1, diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 892ace82d7..88f3b7ef1a 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -604,6 +604,7 @@ def test_area_management(client: TestClient, admin_access_token: str) -> None: "colorg": 112, "colorr": 112, "displayComments": True, + "comments": "", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, diff --git a/tests/storage/business/test_arealink_manager.py b/tests/storage/business/test_arealink_manager.py index b61074b8b7..ce372dccba 100644 --- a/tests/storage/business/test_arealink_manager.py +++ b/tests/storage/business/test_arealink_manager.py @@ -247,6 +247,7 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService): "transmission_capacities": TransmissionCapacity.ENABLED, "asset_type": AssetType.AC, "display_comments": True, + "comments": "", "colorr": 112, "colorg": 112, "colorb": 112, @@ -287,6 +288,7 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService): "transmission_capacities": TransmissionCapacity.ENABLED, "asset_type": AssetType.AC, "display_comments": True, + "comments": "", "colorr": 112, "colorg": 112, "colorb": 112, @@ -543,6 +545,7 @@ def test_get_all_area(): "colorg": 112, "colorr": 112, "display_comments": False, + "comments": "", "filter_synthesis": "hourly, daily, weekly, monthly, annual", "filter_year_by_year": "hourly, daily, weekly, monthly, annual", "hurdles_cost": False, @@ -560,6 +563,7 @@ def test_get_all_area(): "colorg": 112, "colorr": 112, "display_comments": False, + "comments": "", "filter_synthesis": "hourly, daily, weekly, monthly, annual", "filter_year_by_year": "hourly, daily, weekly, monthly, annual", "hurdles_cost": False, @@ -577,6 +581,7 @@ def test_get_all_area(): "colorg": 112, "colorr": 112, "display_comments": False, + "comments": "", "filter_synthesis": "hourly, daily, weekly, monthly, annual", "filter_year_by_year": "hourly, daily, weekly, monthly, annual", "hurdles_cost": False, From 412fe64489c27fa8a8dfa5af324c998a57f96ec0 Mon Sep 17 00:00:00 2001 From: Theo Pascoli Date: Mon, 6 Jan 2025 10:57:54 +0100 Subject: [PATCH 2/3] fix: change a test to explicitely test the (new) comment field --- tests/integration/study_data_blueprint/test_link.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/study_data_blueprint/test_link.py b/tests/integration/study_data_blueprint/test_link.py index 28b8f3da2a..61626f32b1 100644 --- a/tests/integration/study_data_blueprint/test_link.py +++ b/tests/integration/study_data_blueprint/test_link.py @@ -29,7 +29,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ area1_id = preparer.create_area(study_id, name="Area 1")["id"] area2_id = preparer.create_area(study_id, name="Area 2")["id"] - client.post(f"/v1/studies/{study_id}/links", json={"area1": area1_id, "area2": area2_id, "hurdlesCost": True}) + client.post(f"/v1/studies/{study_id}/links", json={"area1": area1_id, "area2": area2_id, "hurdlesCost": True, "comments": "comment"}) res = client.put( f"/v1/studies/{study_id}/links/{area1_id}/{area2_id}", json={"colorr": 150}, @@ -44,7 +44,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ "colorg": 112, "colorr": 150, "displayComments": True, - "comments": "", + "comments": "comment", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": True, @@ -84,7 +84,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ "colorg": 112, "colorr": 150, "displayComments": True, - "comments": "", + "comments": "comment", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, @@ -192,7 +192,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type: "colorg": 170, "colorr": 180, "displayComments": True, - "comments": "", + "comments": "comment", "filterSynthesis": "hourly, daily, weekly, monthly, annual", "filterYearByYear": "hourly, daily, weekly, monthly, annual", "hurdlesCost": False, From 872bf06839605ca0328dd33a7ef5ff6a297b9da5 Mon Sep 17 00:00:00 2001 From: Theo Pascoli Date: Mon, 6 Jan 2025 10:58:10 +0100 Subject: [PATCH 3/3] fix: change a test to explicitely test the (new) comment field --- tests/integration/study_data_blueprint/test_link.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/study_data_blueprint/test_link.py b/tests/integration/study_data_blueprint/test_link.py index 61626f32b1..9fba2a1d5a 100644 --- a/tests/integration/study_data_blueprint/test_link.py +++ b/tests/integration/study_data_blueprint/test_link.py @@ -29,7 +29,10 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ area1_id = preparer.create_area(study_id, name="Area 1")["id"] area2_id = preparer.create_area(study_id, name="Area 2")["id"] - client.post(f"/v1/studies/{study_id}/links", json={"area1": area1_id, "area2": area2_id, "hurdlesCost": True, "comments": "comment"}) + client.post( + f"/v1/studies/{study_id}/links", + json={"area1": area1_id, "area2": area2_id, "hurdlesCost": True, "comments": "comment"}, + ) res = client.put( f"/v1/studies/{study_id}/links/{area1_id}/{area2_id}", json={"colorr": 150},