summaryrefslogtreecommitdiff
path: root/web-server/opendc
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-30 10:32:21 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:42:26 +0200
commit0df6d7e388ec9bd5a514b2b75de8d95550b48802 (patch)
tree5751ac6f89a9b331c18c2231e771cc8b5e8fdcbb /web-server/opendc
parent690818051d0c9768cdaf735acf77ea9e98f00b38 (diff)
Format codebase
Diffstat (limited to 'web-server/opendc')
-rw-r--r--web-server/opendc/api/v2/simulations/simulationId/authorizations/test_endpoint.py28
-rw-r--r--web-server/opendc/api/v2/simulations/simulationId/topologies/test_endpoint.py14
-rw-r--r--web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py35
3 files changed, 52 insertions, 25 deletions
diff --git a/web-server/opendc/api/v2/simulations/simulationId/authorizations/test_endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/authorizations/test_endpoint.py
index 30a1c090..4369d807 100644
--- a/web-server/opendc/api/v2/simulations/simulationId/authorizations/test_endpoint.py
+++ b/web-server/opendc/api/v2/simulations/simulationId/authorizations/test_endpoint.py
@@ -8,20 +8,32 @@ def test_get_authorizations_non_existing(client, mocker):
def test_get_authorizations_not_authorized(client, mocker):
- mocker.patch.object(DB, 'fetch_one', return_value={'_id': '1', 'name': 'test trace', 'authorizations': [{
- 'simulationId': '2',
- 'authorizationLevel': 'OWN'
- }]})
+ mocker.patch.object(DB,
+ 'fetch_one',
+ return_value={
+ '_id': '1',
+ 'name': 'test trace',
+ 'authorizations': [{
+ 'simulationId': '2',
+ 'authorizationLevel': 'OWN'
+ }]
+ })
mocker.patch.object(DB, 'fetch_all', return_value=[])
res = client.get('/api/v2/simulations/1/authorizations')
assert '403' in res.status
def test_get_authorizations(client, mocker):
- mocker.patch.object(DB, 'fetch_one', return_value={'_id': '1', 'name': 'test trace', 'authorizations': [{
- 'simulationId': '1',
- 'authorizationLevel': 'OWN'
- }]})
+ mocker.patch.object(DB,
+ 'fetch_one',
+ return_value={
+ '_id': '1',
+ 'name': 'test trace',
+ 'authorizations': [{
+ 'simulationId': '1',
+ 'authorizationLevel': 'OWN'
+ }]
+ })
mocker.patch.object(DB, 'fetch_all', return_value=[])
res = client.get('/api/v2/simulations/1/authorizations')
assert len(res.json['content']) == 0
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
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
+'''