Skip to content

Commit

Permalink
feat(api): WIP test_read_links
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Jan 7, 2025
1 parent f02ca65 commit 5a13626
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
15 changes: 10 additions & 5 deletions src/antares/craft/service/api_services/link_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(", "))
Expand Down
20 changes: 13 additions & 7 deletions tests/antares/services/api_services/test_link_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5a13626

Please sign in to comment.