Skip to content

Commit

Permalink
Issue #85 Make a few names, comments and some code more clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanKJSchreurs committed Dec 14, 2022
1 parent 8f51fa1 commit 4af81b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,20 @@ def _get_connection_and_backend_service_id(

def get_supported_backend_ids(self) -> List[str]:
"""Get a list containing IDs of the backends that support secondary services."""

# Try the cache first, but its is cached inside the result of get_service_types().
# Getting the service types will also execute querying the capabilities for
# which backends have secondary services.
return self._get_service_types_cached()["supported_backend_ids"]

def _find_ids_supported_backends(self) -> List[str]:
"""Query the backends capabilities to find the ones that support secondary services."""
return [
con.id
for con in self._backends
if con.capabilities().supports_endpoint("/service_types")
]

def service_types(self) -> dict:
"""https://openeo.org/documentation/1.0/developers/api/reference.html#operation/list-service-types"""
service_types = self._get_service_types_cached()["service_types"]
Expand All @@ -698,16 +710,6 @@ def _find_backend_id_for_service_type(self, service_type: str) -> str:
raise ServiceUnsupportedException(service_type)
return backend_id

def _find_ids_supported_backends(self) -> List[str]:
"""Query the backends capabilities find the ones that support secondary services."""
supported_backend_ids = []
for con in self._backends:
capabilities = con.capabilities()
# If we need to cache more capabilities info maybe we could store the full capabilities here.
if capabilities.supports_endpoint("/service_types"):
supported_backend_ids.append(con.id)
return supported_backend_ids

def _get_service_types(self) -> Dict:
"""Returns a dict with cacheable data about the supported backends and service types.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TestAggregatorSecondaryServices:
}
}

def test_get_supported_backend_none_supported(
def test_get_supported_backend_ids_none_supported(
self, multi_backend_connection, config, catalog
):
processing = AggregatorProcessing(backends=multi_backend_connection, catalog=catalog, config=config)
Expand All @@ -166,7 +166,7 @@ def test_get_supported_backend_none_supported(
actual_supported_backends = implementation.get_supported_backend_ids()
assert actual_supported_backends == []

def test_get_supported_backend_all_supported(
def test_get_supported_backend_ids_all_supported(
self, multi_backend_connection, config, catalog, backend1, backend2, requests_mock,
json_capabilities_with_service_types_supported
):
Expand All @@ -178,7 +178,7 @@ def test_get_supported_backend_all_supported(
actual_supported_backends = implementation.get_supported_backend_ids()
assert actual_supported_backends == ["b1", "b2"]

def test_get_supported_backend_only_one_supported(
def test_get_supported_backend_ids_only_one_supported(
self, multi_backend_connection, config, catalog, backend1, backend2, requests_mock,
json_capabilities_with_service_types_supported, json_capabilities_no_endpoints
):
Expand Down

0 comments on commit 4af81b7

Please sign in to comment.