Skip to content

Commit

Permalink
Fix some tests for PR #66 (issue #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Sep 16, 2022
1 parent c969aff commit f593d35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,21 @@ def _normalize_metadata(self, metadata: dict) -> dict:
if "links" not in metadata:
metadata["links"] = []
metadata["links"] = [l for l in metadata["links"] if l.get("rel") not in ("self", "parent", "root")]
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "root"
})
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "parent"
})
metadata["links"].append({
"href": url_for("openeo.collection_by_id", collection_id=cid, _external=True),
"rel": "self"
})
if flask.has_app_context():
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "root"
})
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "parent"
})
metadata["links"].append({
"href": url_for("openeo.collection_by_id", collection_id=cid, _external=True),
"rel": "self"
})
else:
_log.warning("Unable to provide root/parent/self links in collection metadata outside flask app context")
return metadata

def _merge_collection_metadata(self, by_backend: Dict[str, dict]) -> dict:
Expand All @@ -153,7 +156,7 @@ def _merge_collection_metadata(self, by_backend: Dict[str, dict]) -> dict:
"title": getter.first("title", default=cid),
"description": getter.first("description", default=cid),
"type": getter.first("type", default="Collection"),
"links": [l for l in list(getter.merge_arrays("links")) if l.get("rel") not in ("self","parent","root")],
"links": [l for l in list(getter.merge_arrays("links")) if l.get("rel") not in ("self", "parent", "root")],
"summaries": getter.select("summaries").simple_merge()
}
# Note: CRS is required by OGC API: https://docs.opengeospatial.org/is/18-058/18-058.html#_crs_identifier_list
Expand Down
2 changes: 1 addition & 1 deletion tests/partitionedjobs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_job_data(self, user_id, job_id) -> DummyBatchJobData:
def setup_basic_requests_mocks(self):
# Basic collections
self.requests_mock.get(self.backend_url + "/collections", json={"collections": [{"id": "S2"}]})
self.requests_mock.get(self.backend_url + "/collections/S2", json={})
self.requests_mock.get(self.backend_url + "/collections/S2", json={"id": "S2"})
# Batch job handling: list jobs
self.requests_mock.get(self.backend_url + "/jobs", json=self._handle_get_jobs)
# Batch job handling: create job
Expand Down
2 changes: 1 addition & 1 deletion tests/partitionedjobs/test_splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestTileGridSplitter:
@pytest.fixture
def aggregator_processing(self, multi_backend_connection, requests_mock, backend1) -> AggregatorProcessing:
requests_mock.get(backend1 + "/collections", json={"collections": [{"id": "S2"}]})
requests_mock.get(backend1 + "/collections/S2", json={})
requests_mock.get(backend1 + "/collections/S2", json={"id": "S2"})
catalog = AggregatorCollectionCatalog(backends=multi_backend_connection)
return AggregatorProcessing(backends=multi_backend_connection, catalog=catalog)

Expand Down

0 comments on commit f593d35

Please sign in to comment.