diff --git a/pyproject.toml b/pyproject.toml index 6f5f1d1..025d7f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ", "Sean Hoyal ", "Valentina Hutter ", "Gerald Irsiegler "] diff --git a/tests/conftest.py b/tests/conftest.py index 91b5ff7..64388d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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=[]) diff --git a/tests/data/graphs/none_1.json b/tests/data/graphs/none_1.json new file mode 100644 index 0000000..2399d0b --- /dev/null +++ b/tests/data/graphs/none_1.json @@ -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 + } + } +} diff --git a/tests/data/graphs/none_2.json b/tests/data/graphs/none_2.json new file mode 100644 index 0000000..a1c8595 --- /dev/null +++ b/tests/data/graphs/none_2.json @@ -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 + } + } +} diff --git a/tests/data/graphs/none_3.json b/tests/data/graphs/none_3.json new file mode 100644 index 0000000..89554e2 --- /dev/null +++ b/tests/data/graphs/none_3.json @@ -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" + } + } + } + } +} diff --git a/tests/test_pg_parser.py b/tests/test_pg_parser.py index 7773d63..5dd3db5 100644 --- a/tests/test_pg_parser.py +++ b/tests/test_pg_parser.py @@ -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}}