def test_get_s2_info_valid(get_object): """Should work as expected """ bucket = 'sentinel-s2-l1c' scene_path = 'tiles/38/S/NG/2017/10/9/1/' full = False s3 = None request_pays = False expected = { 'acquisition_date': '20171009', 'browseURL': 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/38/S/NG/2017/10/9/1/preview.jpg', 'grid_square': 'NG', 'latitude_band': 'S', 'num': '1', 'path': 'tiles/38/S/NG/2017/10/9/1/', 'sat': 'S2A', 'scene_id': 'S2A_tile_20171009_38SNG_1', 'utm_zone': '38' } assert search.get_s2_info(bucket, scene_path, full, s3, request_pays) == expected get_object.assert_not_called()
def test_get_s2_info_botoError(get_object): """Should work as expected """ get_object.side_effect = ClientError( {'Error': {'Code': 500, 'Message': 'Error'}}, 'get_object') bucket = 'sentinel-s2-l1c' scene_path = 'tiles/38/S/NG/2017/10/9/1/' full = True s3 = None request_pays = False expected = { 'acquisition_date': '20171009', 'browseURL': 'https://sentinel-s2-l1c.s3.amazonaws.com/tiles/38/S/NG/2017/10/9/1/preview.jpg', 'grid_square': 'NG', 'latitude_band': 'S', 'num': '1', 'path': 'tiles/38/S/NG/2017/10/9/1/', 'sat': 'S2A', 'scene_id': 'S2A_tile_20171009_38SNG_1', 'utm_zone': '38'} assert search.get_s2_info(bucket, scene_path, full, s3, request_pays) == expected get_object.assert_called_once()
def test_get_s2_info_validFullPays(get_object): """Should work as expected """ path = os.path.join(os.path.dirname(__file__), f'fixtures/tileInfo.json') with open(path, 'rb') as f: tileInfo = f.read() get_object.return_value = tileInfo bucket = 'sentinel-s2-l1c' scene_path = 'tiles/38/S/NG/2017/10/9/1/' full = True s3 = None request_pays = True expected = { 'acquisition_date': '20171009', 'browseURL': 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/38/S/NG/2017/10/9/1/preview.jpg', 'cloud_coverage': 5.01, 'coverage': 36.52, 'geometry': { 'coordinates': [[[499980.0, 4200000.0], [609780.0, 4200000.0], [609780.0, 4090200.0], [499980.0, 4090200.0], [499980.0, 4200000.0]]], 'crs': { 'properties': { 'name': 'urn:ogc:def:crs:EPSG:8.8.1:32638' }, 'type': 'name' }, 'type': 'Polygon' }, 'grid_square': 'NG', 'latitude_band': 'S', 'num': '1', 'path': 'tiles/38/S/NG/2017/10/9/1/', 'sat': 'S2B', 'scene_id': 'S2B_tile_20171009_38SNG_1', 'utm_zone': '38' } assert search.get_s2_info(bucket, scene_path, full, s3, request_pays) == expected get_object.assert_called_once() assert get_object.call_args[1].get('request_pays')