From 5a136262781443e9290dcb58a7cd9f37428ba19e Mon Sep 17 00:00:00 2001 From: wahadameh Date: Tue, 7 Jan 2025 08:42:27 +0100 Subject: [PATCH] feat(api): WIP test_read_links --- .../craft/service/api_services/link_api.py | 15 +++++++++----- .../services/api_services/test_link_api.py | 20 ++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/antares/craft/service/api_services/link_api.py b/src/antares/craft/service/api_services/link_api.py index ac9c2c11..1543de91 100644 --- a/src/antares/craft/service/api_services/link_api.py +++ b/src/antares/craft/service/api_services/link_api.py @@ -232,11 +232,16 @@ def read_links(self) -> list[Link]: link_style=link_style, link_width=link_width, colorr=color_r, colorg=color_g, colorb=color_b ) - mapping = {"hurdlesCost":"hurdles-cost", "loopFlow":"loop-flow", - "usePhaseShifter":"use-phase-shifter", "transmissionCapacities":"transmission-capacities", - "displayComments":"display-comments", "filterSynthesis":"filter-synthesis", - "filterYearByYear":"filter-year-by-year", "assetType":"asset-type"} - + mapping = { + "hurdlesCost": "hurdles-cost", + "loopFlow": "loop-flow", + "usePhaseShifter": "use-phase-shifter", + "transmissionCapacities": "transmission-capacities", + "displayComments": "display-comments", + "filterSynthesis": "filter-synthesis", + "filterYearByYear": "filter-year-by-year", + "assetType": "asset-type", + } link = {mapping.get(k, k): v for k, v in link.items()} link["filter-synthesis"] = set(link["filter-synthesis"].split(", ")) diff --git a/tests/antares/services/api_services/test_link_api.py b/tests/antares/services/api_services/test_link_api.py index d1027029..24f3a5fd 100644 --- a/tests/antares/services/api_services/test_link_api.py +++ b/tests/antares/services/api_services/test_link_api.py @@ -51,14 +51,20 @@ def expected_link(): "filter-synthesis": set("hourly, daily, weekly, monthly, annual".split(", ")), "filter-year-by-year": set("hourly, daily, weekly, monthly, annual".split(", ")), } - color_r=properties.pop("colorr") - color_b=properties.pop("colorb") - color_g=properties.pop("colorg") - link_width=properties.pop("linkWidth") - link_style=properties.pop("linkStyle") + color_r = properties.pop("colorr") + color_b = properties.pop("colorb") + color_g = properties.pop("colorg") + link_width = properties.pop("linkWidth") + link_style = properties.pop("linkStyle") link_properties = LinkProperties(**properties) - link_ui= LinkUi(colorg=color_g,colorb=color_b,colorr=color_r,link_style=link_style,link_width=link_width) - return Link(area_from=area_from_name, area_to=area_to_name, link_service=link_service, properties=link_properties, ui=link_ui) + link_ui = LinkUi(colorg=color_g, colorb=color_b, colorr=color_r, link_style=link_style, link_width=link_width) + return Link( + area_from=area_from_name, + area_to=area_to_name, + link_service=link_service, + properties=link_properties, + ui=link_ui, + ) class TestCreateAPI: