From 0ba6634268845991a62a01f8dad540f1e6147c02 Mon Sep 17 00:00:00 2001 From: Jorge Andres Herrera Maldonado Date: Tue, 23 Nov 2021 09:37:47 +0100 Subject: [PATCH 1/2] test code for STAC implementation --- tests/test_async_processing_import_export.py | 121 +++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/tests/test_async_processing_import_export.py b/tests/test_async_processing_import_export.py index 5e9fc6448..8395a93e7 100644 --- a/tests/test_async_processing_import_export.py +++ b/tests/test_async_processing_import_export.py @@ -218,6 +218,87 @@ 'version': '1'} +process_chain_stac_import = { + "list": [{ + "id": "importer_1", + "module": "importer", + "inputs": [{ + "import_descr": { + "source": "stac.STAC_Others.rastercube.sentinel-s2-l2a", + "type": "stac", + "semantic_label": "red", + "extent": { + "spatial": { + "bbox": [[30.192, -16.369, 42.834, -0.264]] + }, + "temporal":{ + "interval": [["2021-09-09", "2021-09-12"]] + } + }, + "filter": {} + }, + "param": "map", + "value": "example-red" + } + ] + }], + "version": 1 +} + +process_chain_stac_filter_error_import = { + "list": [{ + "id": "importer_1", + "module": "importer", + "inputs": [{ + "import_descr": { + "source": "stac.STAC_Others.rastercube.sentinel-s2-l2a", + "type": "stac", + "semantic_label": "red", + "extent": { + "spatial": { + "bbox": [[-180, -16.369, 90, -0.264]] + }, + "temporal":{ + "interval": [["2023-09-09", "2022-09-12"]] + } + }, + "filter": {} + }, + "param": "map", + "value": "example-red" + } + ] + }], + "version": 1 +} + +process_chain_stac_source_error_import = { + "list": [{ + "id": "importer_1", + "module": "importer", + "inputs": [{ + "import_descr": { + "source": "sentinel-s2-l2a", + "type": "stac", + "semantic_label": "red", + "extent": { + "spatial": { + "bbox": [[30.192, -16.369, 42.834, -0.264]] + }, + "temporal":{ + "interval": [["2021-09-09", "2021-09-12"]] + } + }, + "filter": {} + }, + "param": "map", + "value": "example-red" + } + ] + }], + "version": 1 +} + class AsyncProcessTestCase(ActiniaResourceTestCaseBase): @@ -323,6 +404,46 @@ def test_sentinel_import_error(self): self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, http_status=400, status="error") + # Test for STAC + @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, + "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + def test_stac_import(self): + + endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' + rv = self.server.post(endpoint, + headers=self.admin_auth_header, + data=json_dumps(process_chain_stac_import), + content_type="application/json") + + self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, + http_status=200, status="finished") + + @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, + "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + def test_stac_source_error_import(self): + + endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' + rv = self.server.post(endpoint, + headers=self.admin_auth_header, + data=json_dumps(process_chain_stac_source_error_import), + content_type="application/json") + + self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, + http_status=400, status="error") + + @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, + "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + def test_stac_source_filter_error_import(self): + + endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' + rv = self.server.post(endpoint, + headers=self.admin_auth_header, + data=json_dumps(process_chain_stac_filter_error_import), + content_type="application/json") + + self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, + http_status=400, status="error") + if __name__ == '__main__': unittest.main() From 8667d66b6ef0e97d4771c49881f90cd2a59232c0 Mon Sep 17 00:00:00 2001 From: Jorge Andres Herrera Maldonado Date: Thu, 9 Dec 2021 17:55:41 +0100 Subject: [PATCH 2/2] STAC verification and small descrption on test function --- tests/test_async_processing_import_export.py | 34 ++++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/test_async_processing_import_export.py b/tests/test_async_processing_import_export.py index 8395a93e7..6b7f21dae 100644 --- a/tests/test_async_processing_import_export.py +++ b/tests/test_async_processing_import_export.py @@ -32,9 +32,15 @@ except ModuleNotFoundError: from test_resource_base import ActiniaResourceTestCaseBase, URL_PREFIX +try: + import actinia_stac_plugin + no_stac_plugin = False +except Exception: + no_stac_plugin = True + __license__ = "GPLv3" __author__ = "Sören Gebbert" -__copyright__ = "Copyright 2016-2018, Sören Gebbert and mundialis GmbH & Co. KG" +__copyright__ = "Copyright 2016-2021, Sören Gebbert and mundialis GmbH & Co. KG" __maintainer__ = "Sören Gebbert" __email__ = "soerengebbert@googlemail.com" @@ -224,9 +230,9 @@ "module": "importer", "inputs": [{ "import_descr": { - "source": "stac.STAC_Others.rastercube.sentinel-s2-l2a", + "source": "stac.defaultStac.rastercube.landsat-8-l1-c1", "type": "stac", - "semantic_label": "red", + "semantic_label": "B1", "extent": { "spatial": { "bbox": [[30.192, -16.369, 42.834, -0.264]] @@ -405,9 +411,11 @@ def test_sentinel_import_error(self): http_status=400, status="error") # Test for STAC - @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, - "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + @unittest.skipIf(no_stac_plugin, "STAC Plugin not installed") def test_stac_import(self): + """ + Code test STAC collection importation with http reponse 200 + """ endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' rv = self.server.post(endpoint, @@ -418,10 +426,12 @@ def test_stac_import(self): self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, http_status=200, status="finished") - @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, - "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + @unittest.skipIf(no_stac_plugin, "STAC Plugin not installed") def test_stac_source_error_import(self): - + """ + Code test STAC collection importation with http reponse 400, + raising error on misstructured, undefined, or missing source ID. + """ endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' rv = self.server.post(endpoint, headers=self.admin_auth_header, @@ -431,10 +441,14 @@ def test_stac_source_error_import(self): self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header, http_status=400, status="error") - @unittest.skipIf('GOOGLE_APPLICATION_CREDENTIALS' not in os.environ and 'GOOGLE_CLOUD_PROJECT' not in os.environ, - "Test is skipped because 'GOOGLE_APPLICATION_CREDENTIALS' and 'GOOGLE_CLOUD_PROJECT' not set") + @unittest.skipIf(no_stac_plugin, "STAC Plugin not installed") def test_stac_source_filter_error_import(self): + """ + Code test STAC collection importation with http reponse 400, + raising error on filtering parameter such as wrong Temportal inteval + or wrong Spatial coordinates in bbox. + """ endpoint = URL_PREFIX + '/locations/nc_spm_08/processing_async_export' rv = self.server.post(endpoint, headers=self.admin_auth_header,