diff --git a/test/test_store.py b/test/test_store.py index c1146db..42191db 100644 --- a/test/test_store.py +++ b/test/test_store.py @@ -21,8 +21,11 @@ import itertools import unittest +from unittest.mock import patch import urllib.request +import dask.array as da +import numpy as np import pytest import requests import xarray as xr @@ -49,8 +52,8 @@ SERVER_URL = "http://localhost:8080" SERVER_ENDPOINT_URL = f"{SERVER_URL}/s3" CDSE_CREDENTIALS = { - "key": "O0M0CUQIDQO9TDZ4D8NR", - "secret": "qPUyXs9G6j8on6MY5KPhQNHuA5uZTqxEscrbBCGx", + "key": "xxx", + "secret": "xxx", } @@ -694,7 +697,67 @@ def test_open_data_stack_mode_no_items_found(self): self.assertEqual(msg, str(cm.output[-1])) @pytest.mark.vcr() - def test_open_data_stack_mode_cdse_sen2(self): + @patch("rioxarray.open_rasterio") + def test_open_data_stack_mode_cdse_sen2(self, mock_rioxarray_open): + mock_data = { + "band_1": ( + ("y", "x"), + da.ones((10980, 10980), chunks=(1024, 1024), dtype=np.uint16), + ), + } + spatial_ref = xr.DataArray( + np.array(0), + attrs={ + "crs_wkt": ( + 'PROJCS["WGS 84 / UTM zone 35N",GEOGCS["WGS 84",DATUM["WGS_1984",' + 'SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],' + 'AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG"' + ',"8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG",' + '"9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_' + 'Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central' + '_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false' + '_easting",500000],PARAMETER["false_northing",0],UNIT["metre"' + ',1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing"' + ',NORTH],AUTHORITY["EPSG","32635"]]' + ), + "semi_major_axis": 6378137.0, + "semi_minor_axis": 6356752.314245179, + "inverse_flattening": 298.257223563, + "reference_ellipsoid_name": "WGS 84", + "longitude_of_prime_meridian": 0.0, + "prime_meridian_name": "Greenwich", + "geographic_crs_name": "WGS 84", + "horizontal_datum_name": "World Geodetic System 1984", + "projected_crs_name": "WGS 84 / UTM zone 35N", + "grid_mapping_name": "transverse_mercator", + "latitude_of_projection_origin": 0.0, + "longitude_of_central_meridian": 27.0, + "false_easting": 500000.0, + "false_northing": 0.0, + "scale_factor_at_central_meridian": 0.9996, + "spatial_ref": ( + 'PROJCS["WGS 84 / UTM zone 35N",GEOGCS["WGS 84",DATUM["WGS_1984",' + 'SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]]' + ',AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG"' + ',"8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG",' + '"9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_' + 'Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_' + 'meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_' + 'easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,' + 'AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",' + 'NORTH],AUTHORITY["EPSG","32635"]]' + ), + "GeoTransform": "600000.0 10.0 0.0 5900040.0 0.0 -10.0", + }, + ) + coords = { + "x": np.arange(600005.0, 709796.0, 10.0), + "y": np.arange(5900035.0, 5790244.0, -10.0), + "spatial_ref": spatial_ref, + } + mock_ds = xr.Dataset(mock_data, coords=coords) + mock_rioxarray_open.return_value = mock_ds + store = new_data_store( DATA_STORE_ID_CDSE, key=CDSE_CREDENTIALS["key"],