From 9678262e9fc2e923dc439d75fb719c57c50adcd3 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Mon, 23 Sep 2024 15:07:06 +0200 Subject: [PATCH] Better error when collections across separate backends #153 --- src/openeo_aggregator/backend.py | 1 + tests/test_backend.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openeo_aggregator/backend.py b/src/openeo_aggregator/backend.py index 398aaeb..4a17da3 100644 --- a/src/openeo_aggregator/backend.py +++ b/src/openeo_aggregator/backend.py @@ -332,6 +332,7 @@ def get_backend_candidates_for_collections(self, collections: Iterable[str]) -> only_on = [ f"{cid!r} only on {list(backends)}" for cid, backends in collection_backends_map.items() + if cid in collections if union.difference(backends) ] raise BackendLookupFailureException( diff --git a/tests/test_backend.py b/tests/test_backend.py index 078d66d..86dd58e 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -1063,11 +1063,11 @@ def test_get_all_metadata_common_collections_merging(self, catalog, backend1, ba def test_get_best_backend_for_collections_basic(self, catalog, backend1, backend2, requests_mock): requests_mock.get( backend1 + "/collections", - json={"collections": [{"id": "S3"}, {"id": "S4"}]}, + json={"collections": [{"id": "S3"}, {"id": "S4"}, {"id": "S666"}]}, ) requests_mock.get( backend2 + "/collections", - json={"collections": [{"id": "S4"}, {"id": "S5"}]}, + json={"collections": [{"id": "S4"}, {"id": "S5"}, {"id": "S777"}]}, ) with pytest.raises(OpenEOApiException, match="Empty collection set given"): catalog.get_backend_candidates_for_collections([])