diff options
| author | jc0b <j@jc0b.computer> | 2020-06-30 14:12:07 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:43:10 +0200 |
| commit | 66b2d85385d05abb590535da60341876ecdbab71 (patch) | |
| tree | 0656f64a4179d419adac86e488e21def7a7fa2b8 /web-server/opendc/api/v2/simulations/simulationId/topologies | |
| parent | 88d8a9cbeae3466230db6bd13120bd4438abbc66 (diff) | |
| parent | c99ef7504a1374170f88b89faeb7e6dec6a55253 (diff) | |
Merge changes with upstream
Diffstat (limited to 'web-server/opendc/api/v2/simulations/simulationId/topologies')
| -rw-r--r-- | web-server/opendc/api/v2/simulations/simulationId/topologies/endpoint.py | 3 | ||||
| -rw-r--r-- | web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/web-server/opendc/api/v2/simulations/simulationId/topologies/endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/topologies/endpoint.py index ab7b7006..952959ca 100644 --- a/web-server/opendc/api/v2/simulations/simulationId/topologies/endpoint.py +++ b/web-server/opendc/api/v2/simulations/simulationId/topologies/endpoint.py @@ -2,7 +2,6 @@ from datetime import datetime from opendc.models.simulation import Simulation from opendc.models.topology import Topology -from opendc.util import exceptions from opendc.util.rest import Response from opendc.util.database import Database @@ -22,7 +21,7 @@ def POST(request): topology.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now())) topology.insert() - simulation.obj['topologyIds'].append(topology.obj['_id']) + simulation.obj['topologyIds'].append(topology.get_id()) simulation.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now())) simulation.update() diff --git a/web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py index 10b5e3c9..cc26e1b0 100644 --- a/web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py +++ b/web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py @@ -6,7 +6,16 @@ def test_add_topology_missing_parameter(client): def test_add_topology(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value={'_id': '1', 'authorizations': [{'simulationId': '1', 'authorizationLevel': 'OWN'}], 'topologyIds': []}) + mocker.patch.object(DB, + 'fetch_one', + return_value={ + '_id': '1', + 'authorizations': [{ + 'simulationId': '1', + 'authorizationLevel': 'OWN' + }], + 'topologyIds': [] + }) mocker.patch.object(DB, 'insert', return_value={ @@ -22,5 +31,6 @@ def test_add_topology(client, mocker): assert 'topologyIds' in res.json['content'] assert '200' in res.status + def test_add_topology_no_authorizations(client, mocker): - pass
\ No newline at end of file + pass |
