summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-25 14:53:54 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-25 14:53:54 +0200
commitaa9b32f8cd1467e9718959f400f6777e5d71737d (patch)
treeb88bbede15108c6855d7f94ded4c7054df186a72 /opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies
parenteb0e0a3bc557c05a70eead388797ab850ea87366 (diff)
parentb7a71e5b4aa77b41ef41deec2ace42b67a5a13a7 (diff)
merge: Integrate v2.1 progress into public repository
This pull request integrates the changes planned for the v2.1 release of OpenDC into the public Github repository in order to sync the progress of both repositories.
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies')
-rw-r--r--opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/__init__.py0
-rw-r--r--opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/endpoint.py31
-rw-r--r--opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py52
3 files changed, 0 insertions, 83 deletions
diff --git a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/__init__.py b/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/__init__.py
+++ /dev/null
diff --git a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/endpoint.py
deleted file mode 100644
index 44a0d575..00000000
--- a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/endpoint.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from datetime import datetime
-
-from opendc.models.project import Project
-from opendc.models.topology import Topology
-from opendc.util.rest import Response
-from opendc.util.database import Database
-
-
-def POST(request):
- """Add a new Topology to the specified project and return it"""
-
- request.check_required_parameters(path={'projectId': 'string'}, body={'topology': {'name': 'string'}})
-
- project = Project.from_id(request.params_path['projectId'])
-
- project.check_exists()
- project.check_user_access(request.google_id, True)
-
- topology = Topology({
- 'projectId': project.get_id(),
- 'name': request.params_body['topology']['name'],
- 'rooms': request.params_body['topology']['rooms'],
- })
-
- topology.insert()
-
- project.obj['topologyIds'].append(topology.get_id())
- project.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now()))
- project.update()
-
- return Response(200, 'Successfully inserted topology.', topology.obj)
diff --git a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py
deleted file mode 100644
index 71e88f00..00000000
--- a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py
+++ /dev/null
@@ -1,52 +0,0 @@
-from opendc.util.database import DB
-
-test_id = 24 * '1'
-
-
-def test_add_topology_missing_parameter(client):
- assert '400' in client.post(f'/v2/projects/{test_id}/topologies').status
-
-
-def test_add_topology(client, mocker):
- mocker.patch.object(DB,
- 'fetch_one',
- return_value={
- '_id': test_id,
- 'authorizations': [{
- 'projectId': test_id,
- 'authorizationLevel': 'OWN'
- }],
- 'topologyIds': []
- })
- mocker.patch.object(DB,
- 'insert',
- return_value={
- '_id': test_id,
- 'datetimeCreated': '000',
- 'datetimeLastEdited': '000',
- 'topologyIds': []
- })
- mocker.patch.object(DB, 'update', return_value={})
- res = client.post(f'/v2/projects/{test_id}/topologies', json={'topology': {'name': 'test project', 'rooms': []}})
- assert 'rooms' in res.json['content']
- assert '200' in res.status
-
-
-def test_add_topology_not_authorized(client, mocker):
- mocker.patch.object(DB,
- 'fetch_one',
- return_value={
- '_id': test_id,
- 'projectId': test_id,
- 'authorizations': [{
- 'projectId': test_id,
- 'authorizationLevel': 'VIEW'
- }]
- })
- assert '403' in client.post(f'/v2/projects/{test_id}/topologies',
- json={
- 'topology': {
- 'name': 'test_topology',
- 'rooms': {}
- }
- }).status