From 676ccde281841005e3f318bf267ea1dbcdf6fc87 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 11:43:07 +0200 Subject: Add experiment POST --- .../api/v2/experiments/experimentId/endpoint.py | 14 ++++--- .../v2/experiments/experimentId/test_endpoint.py | 44 +++++++++++++--------- 2 files changed, 34 insertions(+), 24 deletions(-) (limited to 'web-server/opendc/api/v2/experiments/experimentId') diff --git a/web-server/opendc/api/v2/experiments/experimentId/endpoint.py b/web-server/opendc/api/v2/experiments/experimentId/endpoint.py index 2637fca7..7dacdf48 100644 --- a/web-server/opendc/api/v2/experiments/experimentId/endpoint.py +++ b/web-server/opendc/api/v2/experiments/experimentId/endpoint.py @@ -20,12 +20,14 @@ def PUT(request): """Update this Experiment.""" request.check_required_parameters(path={'experimentId': 'string'}, - body={'experiment': { - 'topologyId': 'string', - 'traceId': 'string', - 'schedulerName': 'string', - 'name': 'string', - }}) + body={ + 'experiment': { + 'topologyId': 'string', + 'traceId': 'string', + 'schedulerName': 'string', + 'name': 'string', + } + }) experiment = Experiment.from_id(request.params_path['experimentId']) diff --git a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py index 0c9c9abc..35b8b762 100644 --- a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py +++ b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py @@ -48,12 +48,15 @@ def test_update_experiment_missing_parameter(client): def test_update_experiment_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put('/api/v2/experiments/1', json={'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - }}).status + assert '404' in client.put('/api/v2/experiments/1', + json={ + 'experiment': { + 'topologyId': '1', + 'traceId': '1', + 'schedulerName': 'default', + 'name': 'test', + } + }).status def test_update_experiment_not_authorized(client, mocker): @@ -68,12 +71,15 @@ def test_update_experiment_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put('/api/v2/experiments/1', json={'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - }}).status + assert '403' in client.put('/api/v2/experiments/1', + json={ + 'experiment': { + 'topologyId': '1', + 'traceId': '1', + 'schedulerName': 'default', + 'name': 'test', + } + }).status def test_update_experiment(client, mocker): @@ -89,12 +95,14 @@ def test_update_experiment(client, mocker): }) mocker.patch.object(DB, 'update', return_value={}) - res = client.put('/api/v2/experiments/1', json={'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - }}) + res = client.put( + '/api/v2/experiments/1', + json={'experiment': { + 'topologyId': '1', + 'traceId': '1', + 'schedulerName': 'default', + 'name': 'test', + }}) assert '200' in res.status -- cgit v1.2.3