Skip to content

Commit

Permalink
feat(api): correcting minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Feb 18, 2025
1 parent 50ad437 commit 2469535
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/antares/craft/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def __init__(self, area_name: str, cluster_name: str, matrix_name: str, message:


class ThermalMatrixUpdateError(Exception):
def __init__(self, area_name: str, cluster_name: str, message: str) -> None:
self.message = f"Could not upload matrix for cluster {cluster_name} inside area {area_name}: " + message
def __init__(self, area_name: str, cluster_name: str, matrix_name: str, message: str) -> None:
self.message = f"Could not upload {matrix_name} for cluster {cluster_name} inside area {area_name}: " + message
super().__init__(self.message)


Expand Down
4 changes: 3 additions & 1 deletion src/antares/craft/service/api_services/services/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def update_thermal_matrix(
try:
upload_series(self._base_url, self.study_id, self._wrapper, matrix, path.as_posix())
except APIError as e:
raise ThermalMatrixUpdateError(thermal_cluster.area_id, thermal_cluster.name, e.message) from e
raise ThermalMatrixUpdateError(
thermal_cluster.area_id, thermal_cluster.name, ts_name.value, e.message
) from e

@override
def get_thermal_matrix(self, thermal_cluster: ThermalCluster, ts_name: ThermalClusterMatrixName) -> pd.DataFrame:
Expand Down
10 changes: 5 additions & 5 deletions tests/antares/services/api_services/test_thermal_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_update_prepro_data_fail(self):
mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404)
with pytest.raises(
ThermalMatrixUpdateError,
match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: "
match=f"Could not upload data for cluster {self.thermal.name} inside area {self.area.id}: "
+ self.antares_web_description_msg,
):
self.thermal.update_prepro_data_matrix(self.matrix)
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_update_prepro_modulation_fail(self):
mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404)
with pytest.raises(
ThermalMatrixUpdateError,
match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: "
match=f"Could not upload modulation for cluster {self.thermal.name} inside area {self.area.id}: "
+ self.antares_web_description_msg,
):
self.thermal.update_prepro_modulation_matrix(self.matrix)
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_update_series_fail(self):
mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404)
with pytest.raises(
ThermalMatrixUpdateError,
match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: "
match=f"Could not upload series for cluster {self.thermal.name} inside area {self.area.id}: "
+ self.antares_web_description_msg,
):
self.thermal.update_series_matrix(self.matrix)
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_update_co2_cost_fail(self):
mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404)
with pytest.raises(
ThermalMatrixUpdateError,
match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: "
match=f"Could not upload CO2Cost for cluster {self.thermal.name} inside area {self.area.id}: "
+ self.antares_web_description_msg,
):
self.thermal.update_co2_cost_matrix(self.matrix)
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_update_fuel_cost_fail(self):
mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404)
with pytest.raises(
ThermalMatrixUpdateError,
match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: "
match=f"Could not upload fuelCost for cluster {self.thermal.name} inside area {self.area.id}: "
+ self.antares_web_description_msg,
):
self.thermal.update_fuel_cost_matrix(self.matrix)

0 comments on commit 2469535

Please sign in to comment.