Skip to content

Commit a4cd184

Browse files
fix aggregate_spatial dummycube tests Open-EO/openeo-geopyspark-driver#577
1 parent 0a92e37 commit a4cd184

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

tests/test_dry_run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,14 +1076,14 @@ def test_aggregate_spatial_read_vector(dry_run_env, dry_run_tracer):
10761076
source_constraints = dry_run_tracer.get_source_constraints(merge=True)
10771077
assert len(source_constraints) == 1
10781078
src, constraints = source_constraints[0]
1079+
(geometries,) = dry_run_tracer.get_geometries()
10791080
assert src == ("load_collection", ("S2_FOOBAR", ()))
10801081
assert constraints == {
10811082
"spatial_extent": {"west": 5.05, "south": 51.21, "east": 5.15, "north": 51.3, "crs": "EPSG:4326"},
1082-
"aggregate_spatial": {"geometries": DelayedVector(geometry_path)},
1083+
"aggregate_spatial": {"geometries": geometries},
10831084
"weak_spatial_extent": {"crs": "EPSG:4326", "east": 5.15, "north": 51.3, "south": 51.21, "west": 5.05},
10841085
}
1085-
geometries, = dry_run_tracer.get_geometries()
1086-
assert isinstance(geometries, DelayedVector)
1086+
assert isinstance(geometries, DriverVectorCube)
10871087

10881088

10891089
def test_aggregate_spatial_get_geometries_feature_collection(
@@ -1605,7 +1605,7 @@ def test_CropSAR_aggregate_spatial_constraint(dry_run_env, dry_run_tracer):
16051605
assert len(constraints_with_geometry) == 3
16061606

16071607
for _, constraints in constraints_with_geometry:
1608-
assert constraints['aggregate_spatial']['geometries'].path == geometry_path
1608+
assert isinstance(constraints["aggregate_spatial"]["geometries"], DriverVectorCube)
16091609
finally:
16101610
del process_registry_100._processes['test', 'CropSAR']
16111611

tests/test_views_execute.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,11 +1268,13 @@ def test_read_vector(api):
12681268
)
12691269
resp = api.check_result(process_graph)
12701270
assert b'NaN' not in resp.data
1271-
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.345]], "2015-08-22T00:00:00Z": [[None], [None]]}
1271+
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.0]], "2015-08-22T00:00:00Z": [[None], [3.0]]}
12721272
params = dummy_backend.last_load_collection_call('PROBAV_L3_S10_TOC_NDVI_333M_V2')
12731273
assert params["spatial_extent"] == {"west": 5, "south": 51, "east": 6, "north": 52, "crs": 'EPSG:4326'}
12741274
assert params["temporal_extent"] == ('2017-11-21', '2017-12-21')
1275-
assert params["aggregate_spatial_geometries"] == DelayedVector(geometry_filename)
1275+
assert isinstance(params["aggregate_spatial_geometries"], DriverVectorCube)
1276+
assert len(params["aggregate_spatial_geometries"].get_cube()) == 2
1277+
assert len(params["aggregate_spatial_geometries"].get_geometries()) == 2
12761278

12771279

12781280
def test_read_vector_no_load_collection_spatial_extent(api):
@@ -1284,11 +1286,12 @@ def test_read_vector_no_load_collection_spatial_extent(api):
12841286
)
12851287
resp = api.check_result(process_graph)
12861288
assert b'NaN' not in resp.data
1287-
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.345]], "2015-08-22T00:00:00Z": [[None], [None]]}
1289+
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.0]], "2015-08-22T00:00:00Z": [[None], [3.0]]}
12881290
params = dummy_backend.last_load_collection_call('PROBAV_L3_S10_TOC_NDVI_333M_V2')
12891291
assert params["spatial_extent"] == {"west": 5.05, "south": 51.21, "east": 5.15, "north": 51.3, "crs": 'EPSG:4326'}
12901292
assert params["temporal_extent"] == ('2017-11-21', '2017-12-21')
1291-
assert params["aggregate_spatial_geometries"] == DelayedVector(geometry_filename)
1293+
assert len(params["aggregate_spatial_geometries"].get_cube()) == 2
1294+
assert len(params["aggregate_spatial_geometries"].get_geometries()) == 2
12921295

12931296

12941297
@pytest.mark.parametrize("udf_code", [
@@ -1595,13 +1598,10 @@ def test_load_collection_without_spatial_extent_incorporates_read_vector_extent(
15951598
preprocess=lambda s: s.replace("PLACEHOLDER", str(get_path("geojson/GeometryCollection01.json")))
15961599
)
15971600
resp = api.check_result(process_graph)
1598-
assert b'NaN' not in resp.data
1599-
assert resp.json == {
1600-
"2015-07-06T00:00:00Z": [[2.345], [2.345]],
1601-
"2015-08-22T00:00:00Z": [[None], [None]]
1602-
}
1603-
params = dummy_backend.last_load_collection_call('PROBAV_L3_S10_TOC_NDVI_333M_V2')
1604-
assert params["spatial_extent"] == {"west": 5.05, "south": 51.21, "east": 5.15, "north": 51.3, "crs": 'EPSG:4326'}
1601+
assert b"NaN" not in resp.data
1602+
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.0]], "2015-08-22T00:00:00Z": [[None], [3.0]]}
1603+
params = dummy_backend.last_load_collection_call("PROBAV_L3_S10_TOC_NDVI_333M_V2")
1604+
assert params["spatial_extent"] == {"west": 5.05, "south": 51.21, "east": 5.15, "north": 51.3, "crs": "EPSG:4326"}
16051605

16061606

16071607
def test_read_vector_from_feature_collection(api):
@@ -1610,13 +1610,10 @@ def test_read_vector_from_feature_collection(api):
16101610
preprocess=lambda s: s.replace("PLACEHOLDER", str(get_path("geojson/FeatureCollection01.json")))
16111611
)
16121612
resp = api.check_result(process_graph)
1613-
assert b'NaN' not in resp.data
1614-
assert resp.json == {
1615-
"2015-07-06T00:00:00Z": [[2.345], [2.345]],
1616-
"2015-08-22T00:00:00Z": [[None], [None]]
1617-
}
1618-
params = dummy_backend.last_load_collection_call('PROBAV_L3_S10_TOC_NDVI_333M_V2')
1619-
assert params["spatial_extent"] == {"west": 5, "south": 51, "east": 6, "north": 52, "crs": 'EPSG:4326'}
1613+
assert b"NaN" not in resp.data
1614+
assert resp.json == {"2015-07-06T00:00:00Z": [[2.345], [2.0]], "2015-08-22T00:00:00Z": [[None], [3.0]]}
1615+
params = dummy_backend.last_load_collection_call("PROBAV_L3_S10_TOC_NDVI_333M_V2")
1616+
assert params["spatial_extent"] == {"west": 5, "south": 51, "east": 6, "north": 52, "crs": "EPSG:4326"}
16201617

16211618

16221619
class TestVectorCubeLoading:

0 commit comments

Comments
 (0)