diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-30 14:01:17 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:42:28 +0200 |
| commit | 1c58ae3b25120ac670b897665bac7d8f18156220 (patch) | |
| tree | 71f8b0bbd8a3044ccb1a8c61b8ed9cc1d4e7fa99 /web-server/opendc/api/v2/simulations | |
| parent | b9dcda0fb4bbb52ebd8a15acf324561a6d687eba (diff) | |
Fix more violations and ensure experimentIds handling
Diffstat (limited to 'web-server/opendc/api/v2/simulations')
3 files changed, 7 insertions, 2 deletions
diff --git a/web-server/opendc/api/v2/simulations/endpoint.py b/web-server/opendc/api/v2/simulations/endpoint.py index 232df2ff..b48ad71b 100644 --- a/web-server/opendc/api/v2/simulations/endpoint.py +++ b/web-server/opendc/api/v2/simulations/endpoint.py @@ -3,7 +3,6 @@ from datetime import datetime from opendc.models.simulation import Simulation from opendc.models.topology import Topology from opendc.models.user import User -from opendc.util import exceptions from opendc.util.database import Database from opendc.util.rest import Response @@ -13,7 +12,7 @@ def POST(request): request.check_required_parameters(body={'simulation': {'name': 'string'}}) - topology = Topology({'name': 'Default topology'}) + topology = Topology({'name': 'Default topology', 'rooms': []}) topology.insert() simulation = Simulation({'simulation': request.params_body['simulation']}) diff --git a/web-server/opendc/api/v2/simulations/simulationId/experiments/endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/experiments/endpoint.py index 2b8aac4d..637b8011 100644 --- a/web-server/opendc/api/v2/simulations/simulationId/experiments/endpoint.py +++ b/web-server/opendc/api/v2/simulations/simulationId/experiments/endpoint.py @@ -29,4 +29,7 @@ def POST(request): experiment.insert() + simulation.obj['experimentIds'].append(experiment.obj['_id']) + simulation.update() + return Response(200, 'Successfully added Experiment.', experiment.obj) diff --git a/web-server/opendc/api/v2/simulations/simulationId/experiments/test_endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/experiments/test_endpoint.py index 6a459a3c..1fe09b10 100644 --- a/web-server/opendc/api/v2/simulations/simulationId/experiments/test_endpoint.py +++ b/web-server/opendc/api/v2/simulations/simulationId/experiments/test_endpoint.py @@ -46,6 +46,7 @@ def test_add_experiment(client, mocker): return_value={ '_id': '1', 'simulationId': '1', + 'experimentIds': ['1'], 'authorizations': [{ 'simulationId': '1', 'authorizationLevel': 'EDIT' @@ -54,6 +55,7 @@ def test_add_experiment(client, mocker): mocker.patch.object(DB, 'insert', return_value={ + '_id': '1', 'topologyId': '1', 'traceId': '1', 'schedulerName': 'default', @@ -61,6 +63,7 @@ def test_add_experiment(client, mocker): 'state': 'QUEUED', 'lastSimulatedTick': 0, }) + mocker.patch.object(DB, 'update', return_value=None) res = client.post( '/api/v2/simulations/1/experiments', json={'experiment': { |
