diff --git a/metanorm/normalizers/geospaas/creodias.py b/metanorm/normalizers/geospaas/resto.py similarity index 82% rename from metanorm/normalizers/geospaas/creodias.py rename to metanorm/normalizers/geospaas/resto.py index 68a79d7..ddbba8e 100644 --- a/metanorm/normalizers/geospaas/creodias.py +++ b/metanorm/normalizers/geospaas/resto.py @@ -1,4 +1,6 @@ -"""Normalizer for the metadata used in the Creodias finder API""" +"""Normalizer for the metadata used in a resto API +(https://github.com/jjrom/resto) +""" import dateutil import dateutil.parser @@ -9,8 +11,8 @@ from ...errors import MetadataNormalizationError -class CreodiasEOFinderMetadataNormalizer(GeoSPaaSMetadataNormalizer): - """Generate the properties of a GeoSPaaS Dataset using Creodias +class RestoAPIMetadataNormalizer(GeoSPaaSMetadataNormalizer): + """Generate the properties of a GeoSPaaS Dataset using resto attributes """ @@ -21,12 +23,10 @@ def check(self, raw_metadata): `raw_metadata['services']['download']['url']` (original location) """ - url = ( - raw_metadata.get('url', '') or - raw_metadata.get('services', {}).get('download', {}).get('url', '') - ) - return any(url.startswith(prefix) for prefix in ('https://datahub.creodias.eu/download/', - 'https://zipper.creodias.eu')) + attributes = set(( + 'collection', 'status', 'license', 'productIdentifier', 'parentIdentifier', 'title', + 'description', 'productType', 'sensorMode', 'resolution', 'services', 'links')) + return attributes.issubset(set(raw_metadata.keys())) @utils.raises(KeyError) def get_entry_title(self, raw_metadata): diff --git a/tests/normalizers/test_creodias.py b/tests/normalizers/test_resto.py similarity index 71% rename from tests/normalizers/test_creodias.py rename to tests/normalizers/test_resto.py index 9fb73dd..f6b3078 100644 --- a/tests/normalizers/test_creodias.py +++ b/tests/normalizers/test_resto.py @@ -1,4 +1,4 @@ -"""Tests for the Creodias metadata normalizer""" +"""Tests for the resto API metadata normalizer""" import unittest import unittest.mock as mock from datetime import datetime @@ -9,36 +9,59 @@ from metanorm.errors import MetadataNormalizationError -class CreodiasEOFinderMetadataNormalizerTestCase(unittest.TestCase): - """Tests for the Creodias API attributes normalizer""" +class RestoAPIMetadataNormalizerTestCase(unittest.TestCase): + """Tests for the restp API attributes normalizer""" def setUp(self): - self.normalizer = normalizers.geospaas.CreodiasEOFinderMetadataNormalizer() + self.normalizer = normalizers.geospaas.RestoAPIMetadataNormalizer() def test_check(self): """Test the checking condition""" - valid_urls = ('https://zipper.creodias.eu/download/023c3fe8-bfac-5b58-a359-6aab4bf30bd6', - 'https://datahub.creodias.eu/download/d4e81902-cc32-42dd-bc45-daf789e593cd') - invalid_url = 'https://apihub.copernicus.eu/' + valid_metadata = { + 'collection': "S2GLC", + 'status': "ONLINE", + 'license': {}, + 'productIdentifier': "/eodata/auxdata/S2GLC/2017/S2GLC_T32TQS_2017", + 'parentIdentifier': None, + 'title': "S2GLC_T32TQS_2017", + 'description': "The S2GLC 2017 product r…ps://s2glc.cbk.waw.pl/].", + 'organisationName': None, + 'startDate': "2019-07-15T00:00:00.000Z", + 'completionDate': "2019-07-15T00:00:00.000Z", + 'productType': "GLC", + 'processingLevel': None, + 'platform': "", + 'instrument': None, + 'resolution': 0, + 'sensorMode': None, + 'orbitNumber': 0, + 'quicklook': None, + 'thumbnail': "https://catalogue.datasp…32TQS_2017/thumbnail.png", + 'updated': "2019-10-04T09:46:30.218Z", + 'published': "2019-10-04T09:46:30.218Z", + 'snowCover': 0, + 'cloudCover': 0, + 'gmlgeometry': '