-
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
Conversation
…ting of the method
tests/integration/test_web_client.py
Outdated
|
||
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 comment
The 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)
src/antares/model/study.py
Outdated
|
||
study_name = json_study.pop("name") | ||
study_version = str(json_study.pop("version")) | ||
json_study.pop("id") |
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 ?
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 comment
The 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
…ting of the method
…ting of the method
src/antares/model/study.py
Outdated
@@ -194,7 +211,13 @@ def service(self) -> BaseStudyService: | |||
return self._study_service | |||
|
|||
def read_areas(self) -> list[Area]: | |||
return self._area_service.read_areas() | |||
""" | |||
Syncronize the internal study object with the object written in an antares study |
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.
typo: Synchronize, also you can add with the actual written etc.
Also you can either remove the Return: or finish your sentence :)
tests/integration/test_web_client.py
Outdated
assert study.service.study_id == actual_study.service.study_id | ||
assert study.name == actual_study.name | ||
assert study.version == actual_study.version | ||
assert study.get_areas()["fr"].id == actual_study.get_areas()["fr"].id |
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.
I would prefer you check that list(study.get_areas.keys()) == list(actual_study.get_areas.keys())
.
Also, for the first area of the list, it could be nice to ensure that the areas contain the same renewable and clusters (just check the names)
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.
2 comments and we're good to go
} | ||
} | ||
|
||
json_thermal = [ |
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.
To simplify your test you can just replace the json you introduce by:
json_thermal = []
json_renewable = []
json_st_storage = []
json_properties = {}
and your test will still pass.
You can even remove these variables and simply pur the [] or {} inside the .get() to make it even simpler
tests/integration/test_web_client.py
Outdated
assert study.name == actual_study.name | ||
assert study.version == actual_study.version | ||
assert list(study.get_areas().keys()) == list(actual_study.get_areas().keys()) | ||
assert ( |
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.
It's better. You can introduce
actual_area_fr = actual_study.get_areas()["fr"]
and expected_area_fr = study.get_areas()["fr"]
to avoid calling get_areas multiple times.
Also I would prefer you do the same check as the ones for areas (line 228) for thermal, storages and renewables as it would check more things.
Last thing, I believe you can also check the settings
…ting of the method
…ting of the method
…ting of the method
read_study
read_study_api
No description provided.