|
14 | 14 |
|
15 | 15 | @pytest.fixture
|
16 | 16 | def con100(requests_mock):
|
17 |
| - requests_mock.get(API_URL + "/", json=build_capabilities(udp=True)) |
| 17 | + requests_mock.get(API_URL + "/", json=build_capabilities(udp=True, validation=True)) |
18 | 18 | con = openeo.connect(API_URL)
|
19 | 19 | return con
|
20 | 20 |
|
@@ -197,6 +197,43 @@ def check_body(request):
|
197 | 197 | assert adapter.called
|
198 | 198 |
|
199 | 199 |
|
| 200 | +def test_store_with_validation(con100, requests_mock, caplog): |
| 201 | + requests_mock.get(API_URL + "/processes", json={"processes": [{"id": "add"}]}) |
| 202 | + validation_mock = requests_mock.post( |
| 203 | + API_URL + "/validation", json={"errors": [{"code": "TooComplex", "message": "Nope"}]} |
| 204 | + ) |
| 205 | + |
| 206 | + two = { |
| 207 | + "add": { |
| 208 | + "process_id": "add", |
| 209 | + "arguments": { |
| 210 | + "x": 1, |
| 211 | + "y": 1, |
| 212 | + }, |
| 213 | + "result": True, |
| 214 | + } |
| 215 | + } |
| 216 | + |
| 217 | + def check_body(request): |
| 218 | + body = request.json() |
| 219 | + assert body == { |
| 220 | + "process_graph": two, |
| 221 | + "public": False, |
| 222 | + } |
| 223 | + return True |
| 224 | + |
| 225 | + udp_mock = requests_mock.put(API_URL + "/process_graphs/two", additional_matcher=check_body) |
| 226 | + |
| 227 | + udp = con100.save_user_defined_process("two", two) |
| 228 | + assert isinstance(udp, RESTUserDefinedProcess) |
| 229 | + |
| 230 | + assert udp_mock.called |
| 231 | + assert validation_mock.called |
| 232 | + assert [(r.levelname, r.getMessage()) for r in caplog.records] == [ |
| 233 | + ("WARNING", "Preflight process graph validation raised: [TooComplex] Nope") |
| 234 | + ] |
| 235 | + |
| 236 | + |
200 | 237 | def test_update(con100, requests_mock):
|
201 | 238 | updated_udp = load_json_resource("data/1.0.0/udp_details.json")
|
202 | 239 |
|
|
0 commit comments