From db776ca262f82fefb2c3f1d9e06e734d9f0cc9d8 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Thu, 1 Dec 2022 17:11:54 +0100 Subject: [PATCH] ServiceMetadata: more optional fields related to Open-EO/openeo-aggregator#78 --- openeo_driver/_version.py | 2 +- openeo_driver/backend.py | 8 ++++---- tests/test_backend.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/openeo_driver/_version.py b/openeo_driver/_version.py index 738b4d11..bac0f87e 100644 --- a/openeo_driver/_version.py +++ b/openeo_driver/_version.py @@ -1 +1 @@ -__version__ = "0.27.0a1" +__version__ = "0.27.1a1" diff --git a/openeo_driver/backend.py b/openeo_driver/backend.py index 39f6c7cd..15d6e655 100644 --- a/openeo_driver/backend.py +++ b/openeo_driver/backend.py @@ -65,12 +65,12 @@ class ServiceMetadata(NamedTuple): # Required fields (no default) id: str - process: dict # TODO: also encapsulate this "process graph with metadata" struct (instead of free-form dict)? url: str type: str - enabled: bool - attributes: dict - configuration: dict + process: dict = None # TODO: also encapsulate this "process graph with metadata" struct (instead of free-form dict)? + enabled: bool = True # TODO: required or with default True? https://github.com/Open-EO/openeo-api/issues/473 + attributes: dict = None + configuration: dict = None # Optional fields (with default) title: str = None diff --git a/tests/test_backend.py b/tests/test_backend.py index 59f1ca55..07361811 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -87,6 +87,18 @@ def test_user_defined_process_metadata_from_dict_extra(): assert udp.description == "Enhance the image with the foo process." +def test_service_metadata_from_dict_essentials(): + service = ServiceMetadata.from_dict( + {"id": "badcafe", "url": "https://oeo.test/srv/f00b67", "type": "WMTS"} + ) + assert service.id == "badcafe" + assert service.url == "https://oeo.test/srv/f00b67" + assert service.type == "WMTS" + assert service.enabled is True + assert service.process is None + assert service.attributes is None + assert service.configuration is None + def test_service_metadata_from_dict_basic(): service = ServiceMetadata.from_dict({ "id": "badcafe", "process": {"id": "ndvi", "process_graph": {}},