diff --git a/tests/antares/services/api_services/test_link_api.py b/tests/antares/services/api_services/test_link_api.py index 9d523dc4..ab3ab6c4 100644 --- a/tests/antares/services/api_services/test_link_api.py +++ b/tests/antares/services/api_services/test_link_api.py @@ -20,7 +20,7 @@ LinkDownloadError, LinkPropertiesUpdateError, LinkUiUpdateError, - LinkUploadError, + LinkUploadError, LinksRetrievalError, ) from antares.craft.model.area import Area from antares.craft.model.commons import FilterOption @@ -214,7 +214,7 @@ def test_create_indirect_capacity_fail(self): f"input/links/{self.area_from.id}/capacities/{self.area_to.id}_indirect" ) - mocker.post(raw_url, status_code=404) + mocker.post(raw_url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( LinkUploadError, @@ -240,7 +240,7 @@ def test_get_parameters_fail(self): f"input/links/{self.area_from.id}/{self.area_to.id}_parameters" ) - mocker.get(raw_url, status_code=404) + mocker.get(raw_url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( LinkDownloadError, @@ -266,7 +266,7 @@ def test_get_indirect_capacity_fail(self): f"input/links/{self.area_from.id}/capacities/{self.area_to.id}_indirect" ) - mocker.get(raw_url, status_code=404) + mocker.get(raw_url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( LinkDownloadError, @@ -292,7 +292,7 @@ def test_get_direct_capacity_fail(self): f"input/links/{self.area_from.id}/capacities/{self.area_to.id}_direct" ) - mocker.get(raw_url, status_code=404) + mocker.get(raw_url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( LinkDownloadError, @@ -324,10 +324,21 @@ def test_read_links(self, expected_link): ] with requests_mock.Mocker() as mocker: - expected_link_list = [expected_link] mocker.get(url_read_links, json=json_links) actual_link_list = self.study.read_links() - assert len(actual_link_list) == len(expected_link_list) - assert expected_link_list[0].id == actual_link_list[0].id - assert expected_link_list[0].properties == actual_link_list[0].properties - assert expected_link_list[0].ui == actual_link_list[0].ui + assert len(actual_link_list) == 1 + actual_link = actual_link_list[0] + assert expected_link.id == actual_link.id + assert expected_link.properties == actual_link.properties + assert expected_link.ui == actual_link.ui + + def test_read_links_fail(self): + with requests_mock.Mocker() as mocker: + raw_url = f"https://antares.com/api/v1/studies/{self.study_id}/links" + mocker.get(raw_url, json={"description": self.antares_web_description_msg}, status_code=404) + + with pytest.raises( + LinksRetrievalError, + match=f"Could not retrieve links from study {self.study_id} : {self.antares_web_description_msg}" + ): + self.study.read_links() \ No newline at end of file diff --git a/tests/integration/test_web_client.py b/tests/integration/test_web_client.py index 9523f9c0..c31cb15d 100644 --- a/tests/integration/test_web_client.py +++ b/tests/integration/test_web_client.py @@ -394,11 +394,12 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop): # assert study got all links links = study.read_links() + assert len(links) == 2 test_link_be_fr = links[0] test_link_de_fr = links[1] assert test_link_be_fr.id == link_be_fr.id + assert test_link_be_fr.properties == link_be_fr.properties assert test_link_de_fr.id == link_de_fr.id - assert len(links) == 2 # tests renewable properties update new_props = RenewableClusterProperties()