Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaHutter committed Sep 29, 2023
1 parent 4cb436f commit 9caa2ec
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
116 changes: 116 additions & 0 deletions tests/data/graphs/fit_curve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"loadcollection1":{
"process_id":"load_collection",
"arguments":{
"bands":[
"B02",
"B03"
],
"id":"boa_sentinel_2",
"spatial_extent":{
"west":11.389,
"east":11.39,
"south":46.349,
"north":46.35
},
"temporal_extent":[
"2016-09-01",
"2018-09-01"
]
}
},
"apply1":{
"process_id":"apply",
"arguments":{
"data":{
"from_node":"loadcollection1"
},
"process":{
"process_graph":{
"clip1":{
"process_id":"clip",
"arguments":{
"max":5000,
"min":0,
"x":{
"from_parameter":"x"
}
},
"result":true
}
}
}
}
},
"fitcurve1":{
"process_id":"fit_curve",
"arguments":{
"data":{
"from_node":"apply1"
},
"dimension":"time",
"function":{
"process_graph":{
"arrayelement1":{
"process_id":"array_element",
"arguments":{
"data":{
"from_parameter":"parameters"
},
"index":0
}
},
"arrayelement2":{
"process_id":"array_element",
"arguments":{
"data":{
"from_parameter":"parameters"
},
"index":1
}
},
"multiply1":{
"process_id":"multiply",
"arguments":{
"x":{
"from_node":"arrayelement2"
},
"y":{
"from_parameter":"x"
}
}
},
"add1":{
"process_id":"add",
"arguments":{
"x":{
"from_node":"arrayelement1"
},
"y":{
"from_node":"multiply1"
}
},
"result":true
}
}
},
"parameters":[
1,
2
]
}
},
"saveresult1":{
"process_id":"save_result",
"arguments":{
"data":{
"from_node":"fitcurve1"
},
"format":"NetCDF",
"options":{

}
},
"result":true
}
}
14 changes: 14 additions & 0 deletions tests/test_pg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ def test_full_parse(process_graph_path):

parsed_graph_from_file.plot()

def test_fit_curve_parse():
flat_process_graph = json.load(open(TEST_DATA_DIR / "graphs" / "fit_curve.json"))
parsed_graph = OpenEOProcessGraph.from_json(json.dumps(flat_process_graph))
assert isinstance(parsed_graph, OpenEOProcessGraph)

# Dry-run to_callable after parsing
mock_process_registry = {
process_id: Process({}, lambda process_id: logger.debug(process_id), "predefined")
for process_id in parsed_graph.required_processes
}
callable = parsed_graph.to_callable(mock_process_registry)

parsed_graph.plot()


def test_from_json_constructor():
flat_process_graph = json.load(open(TEST_DATA_DIR / "graphs" / "fit_rf_pg_0.json"))
Expand Down

0 comments on commit 9caa2ec

Please sign in to comment.