Skip to content

Commit 9f72a9d

Browse files
authored
Update: Extra none tests (#92)
1 parent 444ed5f commit 9f72a9d

File tree

6 files changed

+193
-1
lines changed

6 files changed

+193
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "openeo-pg-parser-networkx"
3-
version = "2024.10.0"
3+
version = "2024.10.1"
44

55
description = "Parse OpenEO process graphs from JSON to traversible Python objects."
66
authors = ["Lukas Weidenholzer <[email protected]>", "Sean Hoyal <[email protected]>", "Valentina Hutter <[email protected]>", "Gerald Irsiegler <[email protected]>"]

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def process_graph_path(request) -> Path:
3737
return request.param
3838

3939

40+
@pytest.fixture
41+
def specific_graph(path) -> dict:
42+
return json.load(path)
43+
44+
4045
@pytest.fixture
4146
def process_registry() -> ProcessRegistry:
4247
registry = ProcessRegistry(wrap_funcs=[])

tests/data/graphs/none_1.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"process_graph": {
3+
"load1": {
4+
"process_id": "load_collection",
5+
"arguments": {
6+
"id": "boa_sentinel_2",
7+
"spatial_extent": {
8+
"west": 5,
9+
"east": 5.1,
10+
"south": 51.2,
11+
"north": 51.3
12+
},
13+
"temporal_extent": [
14+
"2019-07-04T12:00:00+00:00",
15+
"2021-06-22T12:00:00+00:00"
16+
],
17+
"bands": null
18+
}
19+
},
20+
"filtertemporal1": {
21+
"process_id": "filter_temporal",
22+
"arguments": {
23+
"data": {
24+
"from_node": "load1"
25+
},
26+
"extent": [
27+
"2020-08-01",
28+
"2020-08-10"
29+
]
30+
}
31+
},
32+
"filterbbox1": {
33+
"process_id": "filter_bbox",
34+
"arguments": {
35+
"data": {
36+
"from_node": "filtertemporal1"
37+
},
38+
"extent": {
39+
"west": 5.07,
40+
"east": 5.1,
41+
"north": 51.23,
42+
"south": 51.21
43+
}
44+
}
45+
},
46+
"saveresult1": {
47+
"process_id": "save_result",
48+
"arguments": {
49+
"data": {
50+
"from_node": "filterbbox1"
51+
},
52+
"format": "NetCDF",
53+
"options": null
54+
},
55+
"result": true
56+
}
57+
}
58+
}

tests/data/graphs/none_2.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"process_graph": {
3+
"load1": {
4+
"process_id": "load_collection",
5+
"arguments": {
6+
"id": "boa_sentinel_2",
7+
"spatial_extent": {
8+
"west": 5,
9+
"east": 5.1,
10+
"south": 51.2,
11+
"north": 51.3
12+
},
13+
"temporal_extent": [
14+
"2019-07-04T12:00:00+00:00",
15+
"2021-06-22T12:00:00+00:00"
16+
],
17+
"bands": null
18+
}
19+
},
20+
"filtertemporal1": {
21+
"process_id": "filter_temporal",
22+
"arguments": {
23+
"data": {
24+
"from_node": "load1"
25+
},
26+
"extent": [
27+
"2020-08-01",
28+
"2020-08-10"
29+
]
30+
}
31+
},
32+
"filterbbox1": {
33+
"process_id": "filter_bbox",
34+
"arguments": {
35+
"data": {
36+
"from_node": "filtertemporal1"
37+
},
38+
"extent": {
39+
"west": 5.07,
40+
"east": 5.1,
41+
"north": 51.23,
42+
"south": 51.21
43+
}
44+
}
45+
},
46+
"saveresult1": {
47+
"process_id": "save_result",
48+
"arguments": {
49+
"data": {
50+
"from_node": "filterbbox1"
51+
},
52+
"format": "NetCDF",
53+
"options": null
54+
},
55+
"result": true
56+
}
57+
}
58+
}

tests/data/graphs/none_3.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"process_graph": {
3+
"load1": {
4+
"process_id": "load_collection",
5+
"arguments": {
6+
"id": "boa_sentinel_2",
7+
"spatial_extent": {
8+
"west": 16.354249035707454,
9+
"east": 16.397538190976075,
10+
"south": 48.19099103894396,
11+
"north": 48.22215063861063
12+
},
13+
"temporal_extent": null,
14+
"bands": [
15+
"B04"
16+
],
17+
"properties": {}
18+
}
19+
},
20+
"load2": {
21+
"process_id": "load_collection",
22+
"arguments": {
23+
"id": "boa_sentinel_2",
24+
"spatial_extent": {
25+
"west": 16.354249035707454,
26+
"east": 16.397538190976075,
27+
"south": 48.19099103894396,
28+
"north": 48.22215063861063
29+
},
30+
"temporal_extent": [
31+
"2019-01-01T00:00:00Z",
32+
"2019-06-01T00:00:00Z"
33+
],
34+
"bands": null
35+
}
36+
},
37+
"save1": {
38+
"process_id": "save_result",
39+
"arguments": {
40+
"data": {
41+
"from_node": "resample1"
42+
},
43+
"format": "NETCDF"
44+
},
45+
"result": true
46+
},
47+
"resample1": {
48+
"process_id": "resample_cube_spatial",
49+
"arguments": {
50+
"data": {
51+
"from_node": "load1"
52+
},
53+
"target": {
54+
"from_node": "load2"
55+
}
56+
}
57+
}
58+
}
59+
}

tests/test_pg_parser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ def test_string_validation(get_process_graph_with_args):
195195
assert all([isinstance(parsed_arg, str) for parsed_arg in parsed_args])
196196

197197

198+
@pytest.mark.parametrize(
199+
"specific_graph,expected_nodes",
200+
[path for path in zip((TEST_DATA_DIR / "graphs").glob('none_*.json'), [4, 4, 4])],
201+
)
202+
def test_none_parameter(specific_graph, expected_nodes):
203+
with open(specific_graph) as fp:
204+
pg_data = json.load(fp=fp)
205+
206+
parsed_graph = OpenEOProcessGraph(pg_data=pg_data)
207+
assert len(parsed_graph.nodes) == expected_nodes
208+
209+
198210
def test_bounding_box_int_crs(get_process_graph_with_args):
199211
pg = get_process_graph_with_args(
200212
{'spatial_extent': {'west': 0, 'east': 10, 'south': 0, 'north': 10, 'crs': 4326}}

0 commit comments

Comments
 (0)