From 39e1afc69e37262afe375d3a0ebeedf2f36a09e9 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Tue, 10 Oct 2023 21:18:01 +0200 Subject: [PATCH] Issue #195 test_views_execute: run against 1.2 API as well --- setup.py | 2 +- tests/data/pg/1.0/apply_polygon.json | 51 ++++++++++++++++++++++++++++ tests/test_views_execute.py | 29 ++++++++++++++-- 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 tests/data/pg/1.0/apply_polygon.json diff --git a/setup.py b/setup.py index a5fbb707..6d20212d 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ "flask", "werkzeug>=1.0.1,<2.3.0", # https://github.com/Open-EO/openeo-python-driver/issues/187 "requests>=2.28.0", - "openeo>=0.15.0", + "openeo>=0.24.0.a2.dev", "openeo_processes==0.0.4", # 0.0.4 is special build/release, also see https://github.com/Open-EO/openeo-python-driver/issues/152 "gunicorn>=20.0.1", "numpy>=1.22.0", diff --git a/tests/data/pg/1.0/apply_polygon.json b/tests/data/pg/1.0/apply_polygon.json new file mode 100644 index 00000000..d2b3a110 --- /dev/null +++ b/tests/data/pg/1.0/apply_polygon.json @@ -0,0 +1,51 @@ +{ + "collection": { + "process_id": "load_collection", + "arguments": {"id": "S2_FOOBAR"} + }, + "apply": { + "process_id": "apply_polygon", + "arguments": { + "data": {"from_node": "collection"}, + "chunks": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [[[1, 5], [2, 5], [2, 6], [1, 6], [1, 5]]] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [[10, 15], [12, 15], [12, 16], [10, 16], [10, 15]] + ] + } + } + ] + }, + "mask_value": -5, + "process": { + "process_graph": { + "runudf1": { + "process_id": "run_udf", + "arguments": { + "data": {"from_parameter": "data"}, + "udf": "print('hello world')", + "runtime": "Python", + "context": {"param": {"from_parameter": "udfparam"}} + }, + "result": true + } + } + } + }, + "result": true + } +} diff --git a/tests/test_views_execute.py b/tests/test_views_execute.py index c034e40d..9a056cf6 100644 --- a/tests/test_views_execute.py +++ b/tests/test_views_execute.py @@ -43,7 +43,13 @@ from .data import TEST_DATA_ROOT, get_path, load_json -@pytest.fixture(params=["1.0.0"]) +@pytest.fixture( + params=[ + "1.0", + # "1.1", + "1.2", + ] +) def api_version(request): return request.param @@ -52,7 +58,11 @@ def api_version(request): def api(api_version, client, backend_implementation) -> ApiTester: dummy_backend.reset(backend_implementation) - data_root = TEST_DATA_ROOT / "pg" / (".".join(api_version.split(".")[:2])) + if api_version.startswith("1."): + # For now, use "pg/1.0" for all 1.x API requests (no need to differentiate yet) + data_root = TEST_DATA_ROOT / "pg" / "1.0" + else: + raise ValueError(api_version) return ApiTester(api_version=api_version, client=client, data_root=data_root) @@ -2781,6 +2791,8 @@ def test_execute_no_cube_logic(api, process_graph, expected): ], ) def test_text_processes(api, process_id, arguments, expected): + if process_id == "text_merge" and api.api_version_compare >= "1.2": + pytest.skip("text_merge is dropped since API version 1.2") # TODO: null propagation (`text_begins(data=null,...) -> null`) can not be tested at the moment pg = {"t": {"process_id": process_id, "arguments": arguments, "result":True}} assert api.result(pg).assert_status_code(200).json == expected @@ -3531,6 +3543,8 @@ def test_vector_buffer_ogc_crs84(api, distance, unit, expected): def test_load_result(api): + if api.api_version_compare >= "1.2": + pytest.skip("load_result is dropped since API version 1.2") api.check_result("load_result.json") params = dummy_backend.last_load_collection_call("99a605a0-1a10-4ba9-abc1-6898544e25fc") @@ -3538,9 +3552,18 @@ def test_load_result(api): def test_chunk_polygon(api): + if api.api_version_compare >= "1.2": + pytest.skip("chunk_polygon is dropped since API version 1.2") + api.check_result("chunk_polygon.json") params = dummy_backend.last_load_collection_call("S2_FOOBAR") - assert params["spatial_extent"] == {'west': 1.0, 'south': 5.0, 'east': 12.0, 'north': 16.0, 'crs': 'EPSG:4326'} + assert params["spatial_extent"] == {"west": 1.0, "south": 5.0, "east": 12.0, "north": 16.0, "crs": "EPSG:4326"} + + +def test_apply_polygon(api): + api.check_result("apply_polygon.json") + params = dummy_backend.last_load_collection_call("S2_FOOBAR") + assert params["spatial_extent"] == {"west": 1.0, "south": 5.0, "east": 12.0, "north": 16.0, "crs": "EPSG:4326"} def test_fit_class_random_forest(api):