From 0df6d7e388ec9bd5a514b2b75de8d95550b48802 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 10:32:21 +0200 Subject: Format codebase --- .../api/v2/topologies/topologyId/test_endpoint.py | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'web-server/opendc/api/v2/topologies') 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 e54052aa..d16f7ee2 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py +++ b/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py @@ -1,46 +1,51 @@ from opendc.util.database import DB - ''' GET /topologies/{topologyId} ''' + def test_get_topology(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value={ + 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 + 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 + 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={ + 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 + 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 + 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 From 9f87ab4bbab048b527585929135cab80fafd9ef9 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 13:28:18 +0200 Subject: Address a number of pylint issues --- web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'web-server/opendc/api/v2/topologies') 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 d16f7ee2..48bd6846 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py +++ b/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py @@ -9,8 +9,9 @@ def test_get_topology(client, mocker): 'fetch_one', return_value={ '_id': '1', + 'simulationId': '1', 'authorizations': [{ - 'topologyId': '1', + 'simulationId': '1', 'authorizationLevel': 'EDIT' }] }) @@ -28,8 +29,9 @@ def test_get_topology_not_authorized(client, mocker): 'fetch_one', return_value={ '_id': '1', + 'simulationId': '1', 'authorizations': [{ - 'topologyId': '2', + 'simulationId': '2', 'authorizationLevel': 'OWN' }] }) -- cgit v1.2.3 From 1c58ae3b25120ac670b897665bac7d8f18156220 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 14:01:17 +0200 Subject: Fix more violations and ensure experimentIds handling --- web-server/opendc/api/v2/topologies/topologyId/endpoint.py | 1 - 1 file changed, 1 deletion(-) (limited to 'web-server/opendc/api/v2/topologies') diff --git a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py b/web-server/opendc/api/v2/topologies/topologyId/endpoint.py index 6c6ab9c2..a8061d69 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py +++ b/web-server/opendc/api/v2/topologies/topologyId/endpoint.py @@ -1,5 +1,4 @@ from opendc.models.topology import Topology -from opendc.util import exceptions from opendc.util.rest import Response -- cgit v1.2.3