diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e9a1e71..679770ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `DataCube.sar_backscatter()`: add corresponding band names to metadata when enabling "mask", "contributing_area", "local_incidence_angle" or "ellipsoid_incidence_angle" ([#804](https://github.com/Open-EO/openeo-python-client/issues/804)) - Proactively refresh access/bearer token in `MultiBackendJobManager` before launching a job start thread ([#817](https://github.com/Open-EO/openeo-python-client/issues/817)) +- `Connection.list_services()`: Fix list access error for federation extension ## [0.45.0] - 2025-09-17 diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index 4a457c03b..5625ef479 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -848,12 +848,12 @@ def list_services(self) -> list: :return: data_dict: Dict All available services """ # TODO return parsed service objects - services = self.get('/services', expected_status=200).json()["services"] - federation_missing = federation_extension.get_federation_missing(data=services, resource_name="services") + response = self.get("/services", expected_status=200).json() + federation_missing = federation_extension.get_federation_missing(data=response, resource_name="services") federation = self.capabilities().ext_federation_backend_details() return VisualList( "data-table", - data=services, + data=response["services"], parameters={"columns": "services", "missing": federation_missing, "federation": federation}, ) diff --git a/tests/rest/test_connection.py b/tests/rest/test_connection.py index bda3d50c7..0fc0a3976 100644 --- a/tests/rest/test_connection.py +++ b/tests/rest/test_connection.py @@ -3810,6 +3810,63 @@ def test_list_service_types_error(requests_mock): assert m.call_count == 2 +def test_list_services(requests_mock): + requests_mock.get(API_URL, json={"api_version": "1.0.0"}) + conn = Connection(API_URL) + requests_mock.get( + API_URL + "services", + json={ + "services": [ + { + "id": "wms-a3cca9", + "url": "https://openeo.example/wms/wms-a3cca9", + "type": "wms", + "enabled": True, + } + ], + "links": [], + }, + ) + assert conn.list_services() == [ + { + "id": "wms-a3cca9", + "url": "https://openeo.example/wms/wms-a3cca9", + "type": "wms", + "enabled": True, + } + ] + + +def test_list_services_federation_missing(requests_mock): + requests_mock.get(API_URL, json={"api_version": "1.0.0"}) + conn = Connection(API_URL) + requests_mock.get( + API_URL + "services", + json={ + "services": [ + { + "id": "wms-a3cca9", + "url": "https://openeo.example/wms/wms-a3cca9", + "type": "wms", + "enabled": True, + } + ], + "links": [], + "federation:missing": ["oeob"], + }, + ) + services = conn.list_services() + assert services == [ + { + "id": "wms-a3cca9", + "url": "https://openeo.example/wms/wms-a3cca9", + "type": "wms", + "enabled": True, + } + ] + assert services.parameters["missing"] == ["oeob"] + + def test_list_udf_runtimes(requests_mock): requests_mock.get(API_URL, json={"api_version": "1.0.0"}) conn = Connection(API_URL)