summaryrefslogtreecommitdiff
path: root/web-server/opendc/api/v2/topologies
diff options
context:
space:
mode:
Diffstat (limited to 'web-server/opendc/api/v2/topologies')
-rw-r--r--web-server/opendc/api/v2/topologies/topologyId/endpoint.py12
-rw-r--r--web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py35
2 files changed, 17 insertions, 30 deletions
diff --git a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py b/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
index 1dcccb3e..512b050a 100644
--- a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
+++ b/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
@@ -1,7 +1,7 @@
from datetime import datetime
from opendc.util.database import Database
-from opendc.models.simulation import Simulation
+from opendc.models.project import Project
from opendc.models.topology import Topology
from opendc.util.rest import Response
@@ -45,11 +45,11 @@ def DELETE(request):
topology.check_exists()
topology.check_user_access(request.google_id, True)
- simulation = Simulation.from_id(topology.obj['simulationId'])
- simulation.check_exists()
- if request.params_path['topologyId'] in simulation.obj['topologyIds']:
- simulation.obj['topologyIds'].remove(request.params_path['topologyId'])
- simulation.update()
+ project = Project.from_id(topology.obj['projectId'])
+ project.check_exists()
+ if request.params_path['topologyId'] in project.obj['topologyIds']:
+ project.obj['topologyIds'].remove(request.params_path['topologyId'])
+ project.update()
old_object = topology.delete()
diff --git a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py b/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py
index fa88c497..b25cb798 100644
--- a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py
+++ b/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py
@@ -1,7 +1,4 @@
from opendc.util.database import DB
-'''
-GET /topologies/{topologyId}
-'''
def test_get_topology(client, mocker):
@@ -9,9 +6,9 @@ def test_get_topology(client, mocker):
'fetch_one',
return_value={
'_id': '1',
- 'simulationId': '1',
+ 'projectId': '1',
'authorizations': [{
- 'simulationId': '1',
+ 'projectId': '1',
'authorizationLevel': 'EDIT'
}]
})
@@ -29,9 +26,9 @@ def test_get_topology_not_authorized(client, mocker):
'fetch_one',
return_value={
'_id': '1',
- 'simulationId': '1',
+ 'projectId': '1',
'authorizations': [{
- 'simulationId': '2',
+ 'projectId': '2',
'authorizationLevel': 'OWN'
}]
})
@@ -40,16 +37,11 @@ def test_get_topology_not_authorized(client, mocker):
def test_get_topology_no_authorizations(client, mocker):
- mocker.patch.object(DB, 'fetch_one', return_value={'authorizations': []})
+ mocker.patch.object(DB, 'fetch_one', return_value={'projectId': '1', 'authorizations': []})
res = client.get('/api/v2/topologies/1')
assert '403' in res.status
-'''
-PUT /topologies/{topologyId}
-'''
-
-
def test_update_topology_missing_parameter(client):
assert '400' in client.put('/api/v2/topologies/1').status
@@ -64,9 +56,9 @@ def test_update_topology_not_authorized(client, mocker):
'fetch_one',
return_value={
'_id': '1',
- 'simulationId': '1',
+ 'projectId': '1',
'authorizations': [{
- 'simulationId': '1',
+ 'projectId': '1',
'authorizationLevel': 'VIEW'
}]
})
@@ -84,9 +76,9 @@ def test_update_topology(client, mocker):
'fetch_one',
return_value={
'_id': '1',
- 'simulationId': '1',
+ 'projectId': '1',
'authorizations': [{
- 'simulationId': '1',
+ 'projectId': '1',
'authorizationLevel': 'OWN'
}]
})
@@ -100,21 +92,16 @@ def test_update_topology(client, mocker):
}).status
-'''
-DELETE /topologies/{topologyId}
-'''
-
-
def test_delete_topology(client, mocker):
mocker.patch.object(DB,
'fetch_one',
return_value={
'_id': '1',
- 'simulationId': '1',
+ 'projectId': '1',
'googleId': 'test',
'topologyIds': ['1'],
'authorizations': [{
- 'simulationId': '1',
+ 'projectId': '1',
'authorizationLevel': 'OWN'
}]
})