Skip to content

Commit

Permalink
Issue #195 test_views_execute: run against 1.2 API as well
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Oct 10, 2023
1 parent 9519d28 commit ce08ec9
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
51 changes: 51 additions & 0 deletions tests/data/pg/1.0/apply_polygon.json
Original file line number Diff line number Diff line change
@@ -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
}
}
29 changes: 26 additions & 3 deletions tests/test_views_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3531,16 +3543,27 @@ 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")

assert params["temporal_extent"] == ('2019-09-22', '2019-09-22')


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):
Expand Down

0 comments on commit ce08ec9

Please sign in to comment.