Skip to content

Commit

Permalink
reformatting files
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Nov 8, 2024
1 parent e0d2947 commit 19549cb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
54 changes: 28 additions & 26 deletions src/antares/service/api_services/study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
import json
import typing as t
from typing import Optional, List
from typing import List, Optional

from antares.api_conf.api_conf import APIconf
from antares.api_conf.request_wrapper import RequestWrapper
Expand All @@ -38,7 +36,7 @@


def _returns_study_settings(
base_url: str, study_id: str, wrapper: RequestWrapper, update: bool, settings: Optional[StudySettings]
base_url: str, study_id: str, wrapper: RequestWrapper, update: bool, settings: Optional[StudySettings]
) -> Optional[StudySettings]:
settings_base_url = f"{base_url}/studies/{study_id}/config"
mapping = {
Expand Down Expand Up @@ -116,10 +114,10 @@ def read_areas(self) -> List:

base_api_url = f"{self._base_url}/studies/{self.study_id}/areas"
ui_url = "?ui=true"
url_thermal = f"clusters/thermal"
url_renewable = f"clusters/renewable"
url_thermal = "clusters/thermal"
url_renewable = "clusters/renewable"
url_st_storage = "storages"
url_properties_form = f"properties/form"
url_properties_form = "properties/form"

json_resp = self._wrapper.get(base_api_url + ui_url).json()

Expand All @@ -135,37 +133,41 @@ def read_areas(self) -> List:
json_properties = self._wrapper.get(area_url + url_properties_form).json()

for therm in json_thermal:
id_therm = therm.pop('id')
name = therm.pop('name')
id_therm = therm.pop("id")
name = therm.pop("name")

thermal_props=ThermalClusterProperties(**therm)
therm_cluster=ThermalCluster(self.config, area, name, thermal_props)
thermal_props = ThermalClusterProperties(**therm)
therm_cluster = ThermalCluster(self.config, area, name, thermal_props)
thermals.update({id_therm: therm_cluster})

for renew in json_renewable:
id_renew = renew.pop('id')
name = renew.pop('name')
id_renew = renew.pop("id")
name = renew.pop("name")

renew_props=RenewableClusterProperties(**renew)
renew_cluster=RenewableCluster(self.config, area, name, renew_props)
renew_props = RenewableClusterProperties(**renew)
renew_cluster = RenewableCluster(self.config, area, name, renew_props)
renewables.update({id_renew: renew_cluster})

for storage in json_st_storage:
id_storage = storage.pop('id')
name = storage.pop('name')
id_storage = storage.pop("id")
name = storage.pop("name")

storage_props = STStorageProperties(**storage)
st_storage_cl = STStorage(self.config, area, name, storage_props)
st_storage.update({id_storage:st_storage_cl})

area_obj=Area(area,
self.config, self.config,
self.config, self.config,
renewables=renewables,thermals=thermals,
st_storages=st_storage, properties=json_properties)
st_storage.update({id_storage: st_storage_cl})

area_obj = Area(
area,
self.config,
self.config,
self.config,
self.config,
renewables=renewables,
thermals=thermals,
st_storages=st_storage,
properties=json_properties,
)

area_list.append(area_obj)

return area_list


2 changes: 1 addition & 1 deletion src/antares/service/local_services/study_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# This file is part of the Antares project.

from typing import Any, Optional, List
from typing import Any, List, Optional

from antares.config.local_configuration import LocalConfiguration
from antares.model.binding_constraint import BindingConstraint
Expand Down
3 changes: 2 additions & 1 deletion tests/antares/services/api_services/test_study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TestCreateAPI:
ServiceFactory(api, study_id).create_thermal_service(),
ServiceFactory(api, study_id).create_renewable_service(),
)

def test_create_study_test_ok(self) -> None:
with requests_mock.Mocker() as mocker:
expected_url = "https://antares.com/api/v1/studies?name=TestStudy&version=880"
Expand Down Expand Up @@ -198,4 +199,4 @@ def test_create_binding_constraint_fails(self):
self.study.create_binding_constraint(name=constraint_name)

def test_read_areas(self):
pass
pass

0 comments on commit 19549cb

Please sign in to comment.