From 61cf27a9529e503d3c56854c9d664f2d9520213a Mon Sep 17 00:00:00 2001 From: jc0b Date: Thu, 25 Jun 2020 22:11:25 +0200 Subject: GET for topologies with tests --- .../api/v2/topologies/topologyId/test_endpoint.py | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 opendc/api/v2/topologies/topologyId/test_endpoint.py (limited to 'opendc/api/v2/topologies/topologyId/test_endpoint.py') 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 -- cgit v1.2.3