Skip to content

Commit

Permalink
fix(link): add comment attribute in link that was missing and causing…
Browse files Browse the repository at this point in the history
… an 422 error (#2281)
  • Loading branch information
TheoPascoli authored Jan 6, 2025
1 parent e929e3d commit 345b0a7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions antarest/study/business/model/link_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/study_data_blueprint/test_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
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},
Expand All @@ -44,6 +47,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ
"colorg": 112,
"colorr": 150,
"displayComments": True,
"comments": "comment",
"filterSynthesis": "hourly, daily, weekly, monthly, annual",
"filterYearByYear": "hourly, daily, weekly, monthly, annual",
"hurdlesCost": True,
Expand Down Expand Up @@ -83,6 +87,7 @@ def test_link_update(self, client: TestClient, user_access_token: str, study_typ
"colorg": 112,
"colorr": 150,
"displayComments": True,
"comments": "comment",
"filterSynthesis": "hourly, daily, weekly, monthly, annual",
"filterYearByYear": "hourly, daily, weekly, monthly, annual",
"hurdlesCost": False,
Expand Down Expand Up @@ -166,6 +171,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,
Expand All @@ -189,6 +195,7 @@ def test_link_820(self, client: TestClient, user_access_token: str, study_type:
"colorg": 170,
"colorr": 180,
"displayComments": True,
"comments": "comment",
"filterSynthesis": "hourly, daily, weekly, monthly, annual",
"filterYearByYear": "hourly, daily, weekly, monthly, annual",
"hurdlesCost": False,
Expand Down Expand Up @@ -299,6 +306,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,
Expand Down Expand Up @@ -327,6 +335,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,
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/study_data_blueprint/test_table_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def test_lifecycle__nominal(
"colorg",
"colorr",
"displayComments",
"comments",
"filterSynthesis",
"filterYearByYear",
"hurdlesCost",
Expand Down Expand Up @@ -247,6 +248,7 @@ def test_lifecycle__nominal(
"colorg": 150,
"colorr": 200,
"displayComments": False,
"comments": "",
"hurdlesCost": True,
"linkStyle": "plain",
"linkWidth": 2,
Expand All @@ -262,6 +264,7 @@ def test_lifecycle__nominal(
"colorg": 112,
"colorb": 112,
"displayComments": True,
"comments": "",
"hurdlesCost": False,
"linkStyle": "plain",
"linkWidth": 1,
Expand All @@ -277,6 +280,7 @@ def test_lifecycle__nominal(
"colorg": 150,
"colorr": 200,
"displayComments": True,
"comments": "",
"hurdlesCost": True,
"linkStyle": "plain",
"linkWidth": 1,
Expand All @@ -292,6 +296,7 @@ def test_lifecycle__nominal(
"colorg": 112,
"colorr": 112,
"displayComments": True,
"comments": "",
"hurdlesCost": True,
"linkStyle": "plain",
"linkWidth": 1,
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/storage/business/test_arealink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 345b0a7

Please sign in to comment.