Skip to content

Commit ce08ec9

Browse files
committed
Issue #195 test_views_execute: run against 1.2 API as well
1 parent 9519d28 commit ce08ec9

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

tests/data/pg/1.0/apply_polygon.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"collection": {
3+
"process_id": "load_collection",
4+
"arguments": {"id": "S2_FOOBAR"}
5+
},
6+
"apply": {
7+
"process_id": "apply_polygon",
8+
"arguments": {
9+
"data": {"from_node": "collection"},
10+
"chunks": {
11+
"type": "FeatureCollection",
12+
"features": [
13+
{
14+
"type": "Feature",
15+
"properties": {},
16+
"geometry": {
17+
"type": "Polygon",
18+
"coordinates": [[[1, 5], [2, 5], [2, 6], [1, 6], [1, 5]]]
19+
}
20+
},
21+
{
22+
"type": "Feature",
23+
"properties": {},
24+
"geometry": {
25+
"type": "Polygon",
26+
"coordinates": [
27+
[[10, 15], [12, 15], [12, 16], [10, 16], [10, 15]]
28+
]
29+
}
30+
}
31+
]
32+
},
33+
"mask_value": -5,
34+
"process": {
35+
"process_graph": {
36+
"runudf1": {
37+
"process_id": "run_udf",
38+
"arguments": {
39+
"data": {"from_parameter": "data"},
40+
"udf": "print('hello world')",
41+
"runtime": "Python",
42+
"context": {"param": {"from_parameter": "udfparam"}}
43+
},
44+
"result": true
45+
}
46+
}
47+
}
48+
},
49+
"result": true
50+
}
51+
}

tests/test_views_execute.py

+26-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@
4343
from .data import TEST_DATA_ROOT, get_path, load_json
4444

4545

46-
@pytest.fixture(params=["1.0.0"])
46+
@pytest.fixture(
47+
params=[
48+
"1.0",
49+
# "1.1",
50+
"1.2",
51+
]
52+
)
4753
def api_version(request):
4854
return request.param
4955

@@ -52,7 +58,11 @@ def api_version(request):
5258
def api(api_version, client, backend_implementation) -> ApiTester:
5359
dummy_backend.reset(backend_implementation)
5460

55-
data_root = TEST_DATA_ROOT / "pg" / (".".join(api_version.split(".")[:2]))
61+
if api_version.startswith("1."):
62+
# For now, use "pg/1.0" for all 1.x API requests (no need to differentiate yet)
63+
data_root = TEST_DATA_ROOT / "pg" / "1.0"
64+
else:
65+
raise ValueError(api_version)
5666
return ApiTester(api_version=api_version, client=client, data_root=data_root)
5767

5868

@@ -2781,6 +2791,8 @@ def test_execute_no_cube_logic(api, process_graph, expected):
27812791
],
27822792
)
27832793
def test_text_processes(api, process_id, arguments, expected):
2794+
if process_id == "text_merge" and api.api_version_compare >= "1.2":
2795+
pytest.skip("text_merge is dropped since API version 1.2")
27842796
# TODO: null propagation (`text_begins(data=null,...) -> null`) can not be tested at the moment
27852797
pg = {"t": {"process_id": process_id, "arguments": arguments, "result":True}}
27862798
assert api.result(pg).assert_status_code(200).json == expected
@@ -3531,16 +3543,27 @@ def test_vector_buffer_ogc_crs84(api, distance, unit, expected):
35313543

35323544

35333545
def test_load_result(api):
3546+
if api.api_version_compare >= "1.2":
3547+
pytest.skip("load_result is dropped since API version 1.2")
35343548
api.check_result("load_result.json")
35353549
params = dummy_backend.last_load_collection_call("99a605a0-1a10-4ba9-abc1-6898544e25fc")
35363550

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

35393553

35403554
def test_chunk_polygon(api):
3555+
if api.api_version_compare >= "1.2":
3556+
pytest.skip("chunk_polygon is dropped since API version 1.2")
3557+
35413558
api.check_result("chunk_polygon.json")
35423559
params = dummy_backend.last_load_collection_call("S2_FOOBAR")
3543-
assert params["spatial_extent"] == {'west': 1.0, 'south': 5.0, 'east': 12.0, 'north': 16.0, 'crs': 'EPSG:4326'}
3560+
assert params["spatial_extent"] == {"west": 1.0, "south": 5.0, "east": 12.0, "north": 16.0, "crs": "EPSG:4326"}
3561+
3562+
3563+
def test_apply_polygon(api):
3564+
api.check_result("apply_polygon.json")
3565+
params = dummy_backend.last_load_collection_call("S2_FOOBAR")
3566+
assert params["spatial_extent"] == {"west": 1.0, "south": 5.0, "east": 12.0, "north": 16.0, "crs": "EPSG:4326"}
35443567

35453568

35463569
def test_fit_class_random_forest(api):

0 commit comments

Comments
 (0)