diff options
Diffstat (limited to 'web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py')
| -rw-r--r-- | web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py index f3aa111c..a284cf32 100644 --- a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py +++ b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py @@ -7,7 +7,7 @@ def test_get_experiment_non_existing(client, mocker): def test_get_experiment_no_authorizations(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value={'simulationId': '1', 'authorizations': []}) + mocker.patch.object(DB, 'fetch_one', return_value={'projectId': '1', 'authorizations': []}) res = client.get('/api/v2/experiments/1') assert '403' in res.status @@ -16,10 +16,10 @@ def test_get_experiment_not_authorized(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={ - 'simulationId': '1', + 'projectId': '1', '_id': '1', 'authorizations': [{ - 'simulationId': '2', + 'projectId': '2', 'authorizationLevel': 'OWN' }] }) @@ -31,10 +31,10 @@ def test_get_experiment(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={ - 'simulationId': '1', + 'projectId': '1', '_id': '1', 'authorizations': [{ - 'simulationId': '1', + 'projectId': '1', 'authorizationLevel': 'EDIT' }] }) @@ -48,12 +48,11 @@ def test_update_experiment_missing_parameter(client): def test_update_experiment_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put('/api/v2/experiments/1', - json={ - 'experiment': { - 'name': 'test', - } - }).status + assert '404' in client.put('/api/v2/experiments/1', json={ + 'experiment': { + 'name': 'test', + } + }).status def test_update_experiment_not_authorized(client, mocker): @@ -61,19 +60,18 @@ def test_update_experiment_not_authorized(client, mocker): 'fetch_one', return_value={ '_id': '1', - 'simulationId': '1', + 'projectId': '1', 'authorizations': [{ - 'simulationId': '1', + 'projectId': '1', 'authorizationLevel': 'VIEW' }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put('/api/v2/experiments/1', - json={ - 'experiment': { - 'name': 'test', - } - }).status + assert '403' in client.put('/api/v2/experiments/1', json={ + 'experiment': { + 'name': 'test', + } + }).status def test_update_experiment(client, mocker): @@ -81,36 +79,34 @@ def test_update_experiment(client, mocker): 'fetch_one', return_value={ '_id': '1', - 'simulationId': '1', + 'projectId': '1', 'authorizations': [{ - 'simulationId': '1', + 'projectId': '1', 'authorizationLevel': 'OWN' }] }) mocker.patch.object(DB, 'update', return_value={}) - res = client.put( - '/api/v2/experiments/1', - json={'experiment': { - 'name': 'test', - }}) + res = client.put('/api/v2/experiments/1', json={'experiment': { + 'name': 'test', + }}) assert '200' in res.status -def test_delete_simulation_non_existing(client, mocker): +def test_delete_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) assert '404' in client.delete('/api/v2/experiments/1').status -def test_delete_simulation_different_user(client, mocker): +def test_delete_project_different_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={ '_id': '1', - 'simulationId': '1', + 'projectId': '1', 'googleId': 'other_test', 'authorizations': [{ - 'simulationId': '1', + 'projectId': '1', 'authorizationLevel': 'VIEW' }] }) @@ -118,16 +114,16 @@ def test_delete_simulation_different_user(client, mocker): assert '403' in client.delete('/api/v2/experiments/1').status -def test_delete_simulation(client, mocker): +def test_delete_project(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={ '_id': '1', - 'simulationId': '1', + 'projectId': '1', 'googleId': 'test', 'experimentIds': ['1'], 'authorizations': [{ - 'simulationId': '1', + 'projectId': '1', 'authorizationLevel': 'OWN' }] }) |
