-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): add method read_study_api
#22
Changes from 33 commits
bcdf961
d31bba1
e3c5030
e06f118
d581ddb
2ab7da7
6906b17
603cfe7
ab74da8
5b8d269
877f53a
838ae57
bb9c9e4
2dd6b7a
483e4d6
d2f4fd9
6ef393c
ed5aa63
4fcd430
0e16576
8238314
41821a5
e402e5b
671336f
b56994a
d0b8052
af39424
0fd3de8
e21278d
2bdb548
a7e28fe
91d01da
4c2d927
a729713
c4767cf
7d35ba7
e605d28
4b4edd4
f6f1a61
e140264
95b08fc
78c93c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
from antares.model.link import Link, LinkProperties, LinkUi | ||
from antares.model.settings.general import GeneralParameters | ||
from antares.model.settings.study_settings import StudySettings | ||
from antares.model.study import Study, create_study_api | ||
from antares.model.study import Study, create_study_api, read_study_api | ||
from antares.service.service_factory import ServiceFactory | ||
|
||
|
||
|
@@ -199,3 +199,40 @@ def test_create_binding_constraint_fails(self): | |
match=f"Could not create the binding constraint {constraint_name}: {self.antares_web_description_msg}", | ||
): | ||
self.study.create_binding_constraint(name=constraint_name) | ||
|
||
def test_read_study_api(self): | ||
base_url = "https://antares.com/api/v1" | ||
url = f"{base_url}/studies/{self.study_id}" | ||
area_url = f"{url}/areas" | ||
json_study = { | ||
MartinBelthle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"id": "22c52f44-4c2a-407b-862b-490887f93dd8", | ||
"name": "test_read_areas", | ||
"version": "880", | ||
} | ||
|
||
settings = StudySettings() | ||
settings.general_parameters = GeneralParameters(mode="Adequacy") | ||
|
||
config_urls = re.compile(f"https://antares.com/api/v1/studies/{self.study_id}/config/.*") | ||
|
||
with requests_mock.Mocker() as mocker: | ||
mocker.get(url, json=json_study) | ||
mocker.get(config_urls, json={}) | ||
mocker.get(area_url, json={}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could change this to make it return an area to test even further that the created study has an area |
||
actual_study = read_study_api(self.api, self.study_id) | ||
|
||
expected_study_name = json_study.pop("name") | ||
expected_study_id = json_study.pop("id") | ||
expected_study_version = json_study.pop("version") | ||
expected_study_settings = StudySettings(**json_study) | ||
|
||
expected_study = Study( | ||
expected_study_name, | ||
expected_study_version, | ||
ServiceFactory(self.api, expected_study_id, expected_study_name), | ||
expected_study_settings, | ||
) | ||
|
||
assert actual_study.name == expected_study.name | ||
assert actual_study.version == expected_study.version | ||
assert actual_study.service.study_id == expected_study.service.study_id | ||
mehdiwahada marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
from antares.model.settings.general import GeneralParameters, Mode | ||
from antares.model.settings.study_settings import PlaylistParameters, StudySettings | ||
from antares.model.st_storage import STStorageGroup, STStorageMatrixName, STStorageProperties | ||
from antares.model.study import create_study_api | ||
from antares.model.study import create_study_api, read_study_api | ||
from antares.model.thermal import ThermalClusterGroup, ThermalClusterProperties | ||
|
||
from tests.integration.antares_web_desktop import AntaresWebDesktop | ||
|
@@ -51,6 +51,12 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop): | |
|
||
study = create_study_api("antares-craft-test", "880", api_config) | ||
|
||
actual_study = read_study_api(api_config, study.service.study_id) | ||
|
||
assert study.service.study_id == actual_study.service.study_id | ||
assert study.name == actual_study.name | ||
assert study.version == actual_study.version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should also test that the 2 studies contain the same areas name. And the same settings (just test some values if the == doesn't work) |
||
|
||
# tests area creation with default values | ||
area_name = "FR" | ||
area_fr = study.create_area(area_name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove id ?