Skip to content

Commit

Permalink
refactor(api-areas): remove area ui options for the properties form
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Feb 27, 2024
1 parent 50c2c1e commit 6b903fa
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
33 changes: 0 additions & 33 deletions antarest/study/business/areas/properties_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@
# Keep the order
FILTER_OPTIONS = ["hourly", "daily", "weekly", "monthly", "annual"]
DEFAULT_FILTER_VALUE = FILTER_OPTIONS
DEFAULT_UI = {
"color_r": 230,
"color_g": 108,
"color_b": 44,
}


def encode_color(ui: Dict[str, Any]) -> str:
data = {**DEFAULT_UI, **ui}
return f"{data['color_r']},{data['color_g']},{data['color_b']}"


def decode_color(encoded_color: str, current_ui: Optional[Dict[str, int]]) -> Dict[str, Any]:
r, g, b = map(int, encoded_color.split(","))
return {**(current_ui or {}), "color_r": r, "color_g": g, "color_b": b}


def sort_filter_options(options: Iterable[str]) -> List[str]:
Expand All @@ -60,9 +45,6 @@ class AdequacyPatchMode(EnumIgnoreCase):


class PropertiesFormFields(FormFieldsBaseModel):
color: Optional[str] = Field(regex="^\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*$")
pos_x: Optional[float]
pos_y: Optional[float]
energy_cost_unsupplied: Optional[float]
energy_cost_spilled: Optional[float]
non_dispatch_power: Optional[bool]
Expand All @@ -89,21 +71,6 @@ def validation(cls, values: Dict[str, Any]) -> Dict[str, Any]:


FIELDS_INFO: Dict[str, FieldInfo] = {
# `color` must be before `pos_x` and `pos_y`, because they are include in the `decode_color`'s return dict value
"color": {
"path": UI_PATH,
"encode": encode_color,
"decode": decode_color,
"default_value": encode_color(DEFAULT_UI),
},
"pos_x": {
"path": f"{UI_PATH}/x",
"default_value": 0.0,
},
"pos_y": {
"path": f"{UI_PATH}/y",
"default_value": 0.0,
},
"energy_cost_unsupplied": {
"path": THERMAL_PATH.format(field="unserverdenergycost"),
"default_value": 0.0,
Expand Down
9 changes: 0 additions & 9 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,9 +1095,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id:
res_properties_config_json["filterSynthesis"] = set(res_properties_config_json["filterSynthesis"])
res_properties_config_json["filterByYear"] = set(res_properties_config_json["filterByYear"])
assert res_properties_config_json == {
"color": "230,108,44",
"posX": 0.0,
"posY": 0.0,
"energyCostUnsupplied": 0.0,
"energyCostSpilled": 0.0,
"nonDispatchPower": True,
Expand All @@ -1112,9 +1109,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id:
f"/v1/studies/{study_id}/areas/area 1/properties/form",
headers=admin_headers,
json={
"color": "123,108,96",
"posX": 3.4,
"posY": 9.0,
"energyCostUnsupplied": 2.0,
"energyCostSpilled": 4.0,
"nonDispatchPower": False,
Expand All @@ -1130,9 +1124,6 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id:
res_properties_config_json["filterSynthesis"] = set(res_properties_config_json["filterSynthesis"])
res_properties_config_json["filterByYear"] = set(res_properties_config_json["filterByYear"])
assert res_properties_config_json == {
"color": "123,108,96",
"posX": 3.4,
"posY": 9.0,
"energyCostUnsupplied": 2.0,
"energyCostSpilled": 4.0,
"nonDispatchPower": False,
Expand Down

0 comments on commit 6b903fa

Please sign in to comment.