Skip to content

Commit

Permalink
Update: Extra none tests (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeraldIr authored Oct 10, 2024
1 parent 444ed5f commit 9f72a9d
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openeo-pg-parser-networkx"
version = "2024.10.0"
version = "2024.10.1"

description = "Parse OpenEO process graphs from JSON to traversible Python objects."
authors = ["Lukas Weidenholzer <[email protected]>", "Sean Hoyal <[email protected]>", "Valentina Hutter <[email protected]>", "Gerald Irsiegler <[email protected]>"]
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def process_graph_path(request) -> Path:
return request.param


@pytest.fixture
def specific_graph(path) -> dict:
return json.load(path)


@pytest.fixture
def process_registry() -> ProcessRegistry:
registry = ProcessRegistry(wrap_funcs=[])
Expand Down
58 changes: 58 additions & 0 deletions tests/data/graphs/none_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"process_graph": {
"load1": {
"process_id": "load_collection",
"arguments": {
"id": "boa_sentinel_2",
"spatial_extent": {
"west": 5,
"east": 5.1,
"south": 51.2,
"north": 51.3
},
"temporal_extent": [
"2019-07-04T12:00:00+00:00",
"2021-06-22T12:00:00+00:00"
],
"bands": null
}
},
"filtertemporal1": {
"process_id": "filter_temporal",
"arguments": {
"data": {
"from_node": "load1"
},
"extent": [
"2020-08-01",
"2020-08-10"
]
}
},
"filterbbox1": {
"process_id": "filter_bbox",
"arguments": {
"data": {
"from_node": "filtertemporal1"
},
"extent": {
"west": 5.07,
"east": 5.1,
"north": 51.23,
"south": 51.21
}
}
},
"saveresult1": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "filterbbox1"
},
"format": "NetCDF",
"options": null
},
"result": true
}
}
}
58 changes: 58 additions & 0 deletions tests/data/graphs/none_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"process_graph": {
"load1": {
"process_id": "load_collection",
"arguments": {
"id": "boa_sentinel_2",
"spatial_extent": {
"west": 5,
"east": 5.1,
"south": 51.2,
"north": 51.3
},
"temporal_extent": [
"2019-07-04T12:00:00+00:00",
"2021-06-22T12:00:00+00:00"
],
"bands": null
}
},
"filtertemporal1": {
"process_id": "filter_temporal",
"arguments": {
"data": {
"from_node": "load1"
},
"extent": [
"2020-08-01",
"2020-08-10"
]
}
},
"filterbbox1": {
"process_id": "filter_bbox",
"arguments": {
"data": {
"from_node": "filtertemporal1"
},
"extent": {
"west": 5.07,
"east": 5.1,
"north": 51.23,
"south": 51.21
}
}
},
"saveresult1": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "filterbbox1"
},
"format": "NetCDF",
"options": null
},
"result": true
}
}
}
59 changes: 59 additions & 0 deletions tests/data/graphs/none_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"process_graph": {
"load1": {
"process_id": "load_collection",
"arguments": {
"id": "boa_sentinel_2",
"spatial_extent": {
"west": 16.354249035707454,
"east": 16.397538190976075,
"south": 48.19099103894396,
"north": 48.22215063861063
},
"temporal_extent": null,
"bands": [
"B04"
],
"properties": {}
}
},
"load2": {
"process_id": "load_collection",
"arguments": {
"id": "boa_sentinel_2",
"spatial_extent": {
"west": 16.354249035707454,
"east": 16.397538190976075,
"south": 48.19099103894396,
"north": 48.22215063861063
},
"temporal_extent": [
"2019-01-01T00:00:00Z",
"2019-06-01T00:00:00Z"
],
"bands": null
}
},
"save1": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "resample1"
},
"format": "NETCDF"
},
"result": true
},
"resample1": {
"process_id": "resample_cube_spatial",
"arguments": {
"data": {
"from_node": "load1"
},
"target": {
"from_node": "load2"
}
}
}
}
}
12 changes: 12 additions & 0 deletions tests/test_pg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ def test_string_validation(get_process_graph_with_args):
assert all([isinstance(parsed_arg, str) for parsed_arg in parsed_args])


@pytest.mark.parametrize(
"specific_graph,expected_nodes",
[path for path in zip((TEST_DATA_DIR / "graphs").glob('none_*.json'), [4, 4, 4])],
)
def test_none_parameter(specific_graph, expected_nodes):
with open(specific_graph) as fp:
pg_data = json.load(fp=fp)

parsed_graph = OpenEOProcessGraph(pg_data=pg_data)
assert len(parsed_graph.nodes) == expected_nodes


def test_bounding_box_int_crs(get_process_graph_with_args):
pg = get_process_graph_with_args(
{'spatial_extent': {'west': 0, 'east': 10, 'south': 0, 'north': 10, 'crs': 4326}}
Expand Down

0 comments on commit 9f72a9d

Please sign in to comment.