summaryrefslogtreecommitdiff
path: root/opendc/api/v2/topologies/topologyId/test_endpoint.py
diff options
context:
space:
mode:
authorjc0b <j@jc0b.computer>2020-06-25 22:11:25 +0200
committerjc0b <j@jc0b.computer>2020-06-25 22:11:25 +0200
commit61cf27a9529e503d3c56854c9d664f2d9520213a (patch)
tree77b32f3dfd56af806520ed481450f6d3c2f33412 /opendc/api/v2/topologies/topologyId/test_endpoint.py
parent00597ec99f587557b88b9982a2c41a2cb8db8112 (diff)
GET for topologies with tests
Diffstat (limited to 'opendc/api/v2/topologies/topologyId/test_endpoint.py')
-rw-r--r--opendc/api/v2/topologies/topologyId/test_endpoint.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/opendc/api/v2/topologies/topologyId/test_endpoint.py b/opendc/api/v2/topologies/topologyId/test_endpoint.py
new file mode 100644
index 00000000..0e264270
--- /dev/null
+++ b/opendc/api/v2/topologies/topologyId/test_endpoint.py
@@ -0,0 +1,53 @@
+from opendc.util.database import DB
+
+'''
+POST /topologies
+'''
+
+
+
+
+'''
+GET /topologies/{topologyId}
+'''
+
+def test_get_topology(client, mocker):
+ mocker.patch.object(DB, 'fetch_one', return_value={
+ '_id': '1',
+ 'authorizations': [{
+ 'topologyId': '1',
+ 'authorizationLevel': 'EDIT'
+ }]
+ })
+ res = client.get('/api/v2/topologies/1')
+ assert '200' in res.status
+
+def test_get_topology_non_existing(client, mocker):
+ mocker.patch.object(DB, 'fetch_one', return_value=None)
+ assert '404' in client.get('/api/v2/topologies/1').status
+
+def test_get_topology_not_authorized(client, mocker):
+ mocker.patch.object(DB, 'fetch_one', return_value={
+ '_id': '1',
+ 'authorizations': [{
+ 'topologyId': '2',
+ 'authorizationLevel': 'OWN'
+ }]
+ })
+ res = client.get('/api/v2/topologies/1')
+ assert '403' in res.status
+
+def test_get_topology_no_authorizations(client, mocker):
+ mocker.patch.object(DB, 'fetch_one', return_value={'authorizations': []})
+ res = client.get('/api/v2/topologies/1')
+ assert '403' in res.status
+
+
+'''
+PUT /topologies/{topologyId}
+'''
+
+
+'''
+DELETE /topologies/{topologyId}
+''' \ No newline at end of file