From 9761bdd1f2b0f72a2c0fa46b3dee1920a580a26a Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 7 Jul 2020 20:59:38 +0200 Subject: Implement portfolio endpoints --- .../projectId/experiments/test_endpoint.py | 78 ---------------------- 1 file changed, 78 deletions(-) delete mode 100644 web-server/opendc/api/v2/projects/projectId/experiments/test_endpoint.py (limited to 'web-server/opendc/api/v2/projects/projectId/experiments/test_endpoint.py') diff --git a/web-server/opendc/api/v2/projects/projectId/experiments/test_endpoint.py b/web-server/opendc/api/v2/projects/projectId/experiments/test_endpoint.py deleted file mode 100644 index 11b79154..00000000 --- a/web-server/opendc/api/v2/projects/projectId/experiments/test_endpoint.py +++ /dev/null @@ -1,78 +0,0 @@ -from opendc.util.database import DB - - -def test_add_experiment_missing_parameter(client): - assert '400' in client.post('/api/v2/projects/1/experiments').status - - -def test_add_experiment_non_existing_project(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.post('/api/v2/projects/1/experiments', - json={ - 'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - } - }).status - - -def test_add_experiment_not_authorized(client, mocker): - mocker.patch.object(DB, - 'fetch_one', - return_value={ - '_id': '1', - 'projectId': '1', - 'authorizations': [{ - 'projectId': '1', - 'authorizationLevel': 'VIEW' - }] - }) - assert '403' in client.post('/api/v2/projects/1/experiments', - json={ - 'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - } - }).status - - -def test_add_experiment(client, mocker): - mocker.patch.object(DB, - 'fetch_one', - return_value={ - '_id': '1', - 'projectId': '1', - 'experimentIds': ['1'], - 'authorizations': [{ - 'projectId': '1', - 'authorizationLevel': 'EDIT' - }] - }) - mocker.patch.object(DB, - 'insert', - return_value={ - '_id': '1', - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - 'state': 'QUEUED', - 'lastSimulatedTick': 0, - }) - mocker.patch.object(DB, 'update', return_value=None) - res = client.post( - '/api/v2/projects/1/experiments', - json={'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', - 'name': 'test', - }}) - assert 'topologyId' in res.json['content'] - assert 'state' in res.json['content'] - assert 'lastSimulatedTick' in res.json['content'] - assert '200' in res.status -- cgit v1.2.3