Skip to content

Commit

Permalink
feat(api): cover raising errors when deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
salemsd committed Jan 8, 2025
1 parent f8cf741 commit 2912727
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CONCATENATED_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ Simulator](https://github.com/AntaresSimulatorTeam/Antares_Simulator).
3) To flesh out the documentation see [mkdoc guides](https://www.mkdocs.org/user-guide/).


v0.1.6 (2025-01-08)
-------------------

- Fix concatenate CONCATENATED_README.md files for single Readme at pypi.org

v0.1.5 (2025-01-08)
-------------------

Expand Down
2 changes: 2 additions & 0 deletions src/antares/craft/service/api_services/study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def delete_outputs(self) -> None:
try:
response = self._wrapper.get(outputs_url)
outputs_json_list = response.json()
if not outputs_json_list:
raise OutputsRetrievalError(self.study_id, "No outputs to delete.")
for output in outputs_json_list:
output_name = output["name"]
self.delete_output(output_name)
Expand Down
14 changes: 14 additions & 0 deletions tests/antares/services/api_services/test_study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
BindingConstraintCreationError,
ConstraintRetrievalError,
LinkCreationError,
OutputDeletionError,
OutputsRetrievalError,
SimulationFailedError,
SimulationTimeOutError,
Expand Down Expand Up @@ -609,6 +610,13 @@ def test_delete_output(self):

assert output_name not in self.study.get_outputs()

# failing
error_message = "Output deletion failed"
mocker.delete(delete_url, json={"description": error_message}, status_code=404)

with pytest.raises(OutputDeletionError, match=error_message):
self.study.delete_output(output_name)

def test_delete_outputs(self):
with requests_mock.Mocker() as mocker:
outputs_url = f"https://antares.com/api/v1/studies/{self.study_id}/outputs"
Expand All @@ -630,3 +638,9 @@ def test_delete_outputs(self):
self.study.delete_outputs()

assert len(self.study.get_outputs()) == 0

# failing
error_message = "Output deletion failed"
mocker.get(outputs_url, json={"description": error_message}, status_code=404)
with pytest.raises(OutputsRetrievalError, match=error_message):
self.study.delete_outputs()

0 comments on commit 2912727

Please sign in to comment.