diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-10-27 23:12:48 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-10-27 23:26:21 +0100 |
| commit | 9fdd26b50e17c757dfa4a0874d87d929ac9ac242 (patch) | |
| tree | ba71bb4439a5e5fb3b7f6f0d211afd43a8cad83f /api/opendc | |
| parent | 45c3adb6fdfed5c191d8a14562eaabbd54c5c91b (diff) | |
Remove api prefix from path
This change removes the `api` prefix required by the API server in the
path, given that we have started to host the API on its own domain
(api.opendc.org) and thus does not need a prefix.
Diffstat (limited to 'api/opendc')
17 files changed, 92 insertions, 92 deletions
diff --git a/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py index 84ad2830..e5982b7f 100644 --- a/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py @@ -4,12 +4,12 @@ test_id = 24 * '1' def test_add_scenario_missing_parameter(client): - assert '400' in client.post('/api/v2/portfolios/1/scenarios').status + assert '400' in client.post('/v2/portfolios/1/scenarios').status def test_add_scenario_non_existing_portfolio(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.post(f'/api/v2/portfolios/{test_id}/scenarios', + assert '404' in client.post(f'/v2/portfolios/{test_id}/scenarios', json={ 'scenario': { 'name': 'test', @@ -41,7 +41,7 @@ def test_add_scenario_not_authorized(client, mocker): 'authorizationLevel': 'VIEW' }] }) - assert '403' in client.post(f'/api/v2/portfolios/{test_id}/scenarios', + assert '403' in client.post(f'/v2/portfolios/{test_id}/scenarios', json={ 'scenario': { 'name': 'test', @@ -102,7 +102,7 @@ def test_add_scenario(client, mocker): }) mocker.patch.object(DB, 'update', return_value=None) res = client.post( - f'/api/v2/portfolios/{test_id}/scenarios', + f'/v2/portfolios/{test_id}/scenarios', json={ 'scenario': { 'name': 'test', diff --git a/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py index 2d9d8d13..52f71aa4 100644 --- a/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py @@ -6,12 +6,12 @@ test_id_2 = 24 * '2' def test_get_portfolio_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/portfolios/{test_id}').status + assert '404' in client.get(f'/v2/portfolios/{test_id}').status def test_get_portfolio_no_authorizations(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'projectId': test_id, 'authorizations': []}) - res = client.get(f'/api/v2/portfolios/{test_id}') + res = client.get(f'/v2/portfolios/{test_id}') assert '403' in res.status @@ -26,7 +26,7 @@ def test_get_portfolio_not_authorized(client, mocker): 'authorizationLevel': 'OWN' }] }) - res = client.get(f'/api/v2/portfolios/{test_id}') + res = client.get(f'/v2/portfolios/{test_id}') assert '403' in res.status @@ -41,17 +41,17 @@ def test_get_portfolio(client, mocker): 'authorizationLevel': 'EDIT' }] }) - res = client.get(f'/api/v2/portfolios/{test_id}') + res = client.get(f'/v2/portfolios/{test_id}') assert '200' in res.status def test_update_portfolio_missing_parameter(client): - assert '400' in client.put(f'/api/v2/portfolios/{test_id}').status + assert '400' in client.put(f'/v2/portfolios/{test_id}').status def test_update_portfolio_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/portfolios/{test_id}', json={ + assert '404' in client.put(f'/v2/portfolios/{test_id}', json={ 'portfolio': { 'name': 'test', 'targets': { @@ -74,7 +74,7 @@ def test_update_portfolio_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put(f'/api/v2/portfolios/{test_id}', json={ + assert '403' in client.put(f'/v2/portfolios/{test_id}', json={ 'portfolio': { 'name': 'test', 'targets': { @@ -102,7 +102,7 @@ def test_update_portfolio(client, mocker): }) mocker.patch.object(DB, 'update', return_value={}) - res = client.put(f'/api/v2/portfolios/{test_id}', json={'portfolio': { + res = client.put(f'/v2/portfolios/{test_id}', json={'portfolio': { 'name': 'test', 'targets': { 'enabledMetrics': ['test'], @@ -114,7 +114,7 @@ def test_update_portfolio(client, mocker): def test_delete_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/portfolios/{test_id}').status + assert '404' in client.delete(f'/v2/portfolios/{test_id}').status def test_delete_project_different_user(client, mocker): @@ -130,7 +130,7 @@ def test_delete_project_different_user(client, mocker): }] }) mocker.patch.object(DB, 'delete_one', return_value=None) - assert '403' in client.delete(f'/api/v2/portfolios/{test_id}').status + assert '403' in client.delete(f'/v2/portfolios/{test_id}').status def test_delete_project(client, mocker): @@ -148,5 +148,5 @@ def test_delete_project(client, mocker): }) mocker.patch.object(DB, 'delete_one', return_value={}) mocker.patch.object(DB, 'update', return_value=None) - res = client.delete(f'/api/v2/portfolios/{test_id}') + res = client.delete(f'/v2/portfolios/{test_id}') assert '200' in res.status diff --git a/api/opendc/api/v2/prefabs/authorizations/test_endpoint.py b/api/opendc/api/v2/prefabs/authorizations/test_endpoint.py index 6ca0448e..6d36d428 100644 --- a/api/opendc/api/v2/prefabs/authorizations/test_endpoint.py +++ b/api/opendc/api/v2/prefabs/authorizations/test_endpoint.py @@ -66,6 +66,6 @@ def test_get_authorizations(client, mocker): }] ] mocker.patch.object(DB, 'fetch_one', return_value={'_id': test_id}) - res = client.get('/api/v2/prefabs/authorizations') + res = client.get('/v2/prefabs/authorizations') assert '200' in res.status diff --git a/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py b/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py index 28a71861..2daeb6bf 100644 --- a/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py +++ b/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py @@ -7,7 +7,7 @@ test_id_2 = 24 * '2' def test_get_prefab_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/prefabs/{test_id}').status + assert '404' in client.get(f'/v2/prefabs/{test_id}').status def test_get_private_prefab_not_authorized(client, mocker): @@ -23,7 +23,7 @@ def test_get_private_prefab_not_authorized(client, mocker): '_id': test_id } ] - res = client.get(f'/api/v2/prefabs/{test_id}') + res = client.get(f'/v2/prefabs/{test_id}') assert '403' in res.status @@ -40,7 +40,7 @@ def test_get_private_prefab(client, mocker): '_id': test_id } ] - res = client.get(f'/api/v2/prefabs/{test_id}') + res = client.get(f'/v2/prefabs/{test_id}') assert '200' in res.status @@ -57,17 +57,17 @@ def test_get_public_prefab(client, mocker): '_id': test_id } ] - res = client.get(f'/api/v2/prefabs/{test_id}') + res = client.get(f'/v2/prefabs/{test_id}') assert '200' in res.status def test_update_prefab_missing_parameter(client): - assert '400' in client.put(f'/api/v2/prefabs/{test_id}').status + assert '400' in client.put(f'/v2/prefabs/{test_id}').status def test_update_prefab_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/prefabs/{test_id}', json={'prefab': {'name': 'S'}}).status + assert '404' in client.put(f'/v2/prefabs/{test_id}', json={'prefab': {'name': 'S'}}).status def test_update_prefab_not_authorized(client, mocker): @@ -84,7 +84,7 @@ def test_update_prefab_not_authorized(client, mocker): } ] mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put(f'/api/v2/prefabs/{test_id}', json={'prefab': {'name': 'test prefab', 'rack': {}}}).status + assert '403' in client.put(f'/v2/prefabs/{test_id}', json={'prefab': {'name': 'test prefab', 'rack': {}}}).status def test_update_prefab(client, mocker): @@ -101,13 +101,13 @@ def test_update_prefab(client, mocker): } ] mocker.patch.object(DB, 'update', return_value={}) - res = client.put(f'/api/v2/prefabs/{test_id}', json={'prefab': {'name': 'test prefab', 'rack': {}}}) + res = client.put(f'/v2/prefabs/{test_id}', json={'prefab': {'name': 'test prefab', 'rack': {}}}) assert '200' in res.status def test_delete_prefab_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/prefabs/{test_id}').status + assert '404' in client.delete(f'/v2/prefabs/{test_id}').status def test_delete_prefab_different_user(client, mocker): @@ -124,7 +124,7 @@ def test_delete_prefab_different_user(client, mocker): } ] mocker.patch.object(DB, 'delete_one', return_value=None) - assert '403' in client.delete(f'/api/v2/prefabs/{test_id}').status + assert '403' in client.delete(f'/v2/prefabs/{test_id}').status def test_delete_prefab(client, mocker): @@ -141,5 +141,5 @@ def test_delete_prefab(client, mocker): } ] mocker.patch.object(DB, 'delete_one', return_value={'prefab': {'name': 'name'}}) - res = client.delete(f'/api/v2/prefabs/{test_id}') + res = client.delete(f'/v2/prefabs/{test_id}') assert '200' in res.status diff --git a/api/opendc/api/v2/prefabs/test_endpoint.py b/api/opendc/api/v2/prefabs/test_endpoint.py index affa24c9..39a78c21 100644 --- a/api/opendc/api/v2/prefabs/test_endpoint.py +++ b/api/opendc/api/v2/prefabs/test_endpoint.py @@ -4,7 +4,7 @@ test_id = 24 * '1' def test_add_prefab_missing_parameter(client): - assert '400' in client.post('/api/v2/prefabs').status + assert '400' in client.post('/v2/prefabs').status def test_add_prefab(client, mocker): @@ -17,7 +17,7 @@ def test_add_prefab(client, mocker): 'datetimeLastEdited': '000', 'authorId': test_id }) - res = client.post('/api/v2/prefabs', json={'prefab': {'name': 'test prefab'}}) + res = client.post('/v2/prefabs', json={'prefab': {'name': 'test prefab'}}) assert 'datetimeCreated' in res.json['content'] assert 'datetimeLastEdited' in res.json['content'] assert 'authorId' in res.json['content'] diff --git a/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py b/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py index d2d7cba1..bebd6cff 100644 --- a/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py @@ -7,7 +7,7 @@ test_id_2 = 24 * '2' def test_get_authorizations_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) mocker.patch.object(DB, 'fetch_all', return_value=None) - assert '404' in client.get(f'/api/v2/projects/{test_id}/authorizations').status + assert '404' in client.get(f'/v2/projects/{test_id}/authorizations').status def test_get_authorizations_not_authorized(client, mocker): @@ -22,7 +22,7 @@ def test_get_authorizations_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'fetch_all', return_value=[]) - res = client.get(f'/api/v2/projects/{test_id}/authorizations') + res = client.get(f'/v2/projects/{test_id}/authorizations') assert '403' in res.status @@ -38,6 +38,6 @@ def test_get_authorizations(client, mocker): }] }) mocker.patch.object(DB, 'fetch_all', return_value=[]) - res = client.get(f'/api/v2/projects/{test_id}/authorizations') + res = client.get(f'/v2/projects/{test_id}/authorizations') assert len(res.json['content']) == 0 assert '200' in res.status diff --git a/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py b/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py index 2a2f777d..04c699b5 100644 --- a/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py @@ -4,12 +4,12 @@ test_id = 24 * '1' def test_add_portfolio_missing_parameter(client): - assert '400' in client.post(f'/api/v2/projects/{test_id}/portfolios').status + assert '400' in client.post(f'/v2/projects/{test_id}/portfolios').status def test_add_portfolio_non_existing_project(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.post(f'/api/v2/projects/{test_id}/portfolios', + assert '404' in client.post(f'/v2/projects/{test_id}/portfolios', json={ 'portfolio': { 'name': 'test', @@ -32,7 +32,7 @@ def test_add_portfolio_not_authorized(client, mocker): 'authorizationLevel': 'VIEW' }] }) - assert '403' in client.post(f'/api/v2/projects/{test_id}/portfolios', + assert '403' in client.post(f'/v2/projects/{test_id}/portfolios', json={ 'portfolio': { 'name': 'test', @@ -70,7 +70,7 @@ def test_add_portfolio(client, mocker): }) mocker.patch.object(DB, 'update', return_value=None) res = client.post( - f'/api/v2/projects/{test_id}/portfolios', + f'/v2/projects/{test_id}/portfolios', json={ 'portfolio': { 'name': 'test', diff --git a/api/opendc/api/v2/projects/projectId/test_endpoint.py b/api/opendc/api/v2/projects/projectId/test_endpoint.py index 43fa5eed..f9ffaf37 100644 --- a/api/opendc/api/v2/projects/projectId/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/test_endpoint.py @@ -6,12 +6,12 @@ test_id_2 = 24 * '2' def test_get_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/projects/{test_id}').status + assert '404' in client.get(f'/v2/projects/{test_id}').status def test_get_project_no_authorizations(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'authorizations': []}) - res = client.get(f'/api/v2/projects/{test_id}') + res = client.get(f'/v2/projects/{test_id}') assert '403' in res.status @@ -25,7 +25,7 @@ def test_get_project_not_authorized(client, mocker): 'authorizationLevel': 'OWN' }] }) - res = client.get(f'/api/v2/projects/{test_id}') + res = client.get(f'/v2/projects/{test_id}') assert '403' in res.status @@ -39,17 +39,17 @@ def test_get_project(client, mocker): 'authorizationLevel': 'EDIT' }] }) - res = client.get(f'/api/v2/projects/{test_id}') + res = client.get(f'/v2/projects/{test_id}') assert '200' in res.status def test_update_project_missing_parameter(client): - assert '400' in client.put(f'/api/v2/projects/{test_id}').status + assert '400' in client.put(f'/v2/projects/{test_id}').status def test_update_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/projects/{test_id}', json={'project': {'name': 'S'}}).status + assert '404' in client.put(f'/v2/projects/{test_id}', json={'project': {'name': 'S'}}).status def test_update_project_not_authorized(client, mocker): @@ -63,7 +63,7 @@ def test_update_project_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put(f'/api/v2/projects/{test_id}', json={'project': {'name': 'S'}}).status + assert '403' in client.put(f'/v2/projects/{test_id}', json={'project': {'name': 'S'}}).status def test_update_project(client, mocker): @@ -78,13 +78,13 @@ def test_update_project(client, mocker): }) mocker.patch.object(DB, 'update', return_value={}) - res = client.put(f'/api/v2/projects/{test_id}', json={'project': {'name': 'S'}}) + res = client.put(f'/v2/projects/{test_id}', json={'project': {'name': 'S'}}) assert '200' in res.status def test_delete_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/projects/{test_id}').status + assert '404' in client.delete(f'/v2/projects/{test_id}').status def test_delete_project_different_user(client, mocker): @@ -100,7 +100,7 @@ def test_delete_project_different_user(client, mocker): 'topologyIds': [] }) mocker.patch.object(DB, 'delete_one', return_value=None) - assert '403' in client.delete(f'/api/v2/projects/{test_id}').status + assert '403' in client.delete(f'/v2/projects/{test_id}').status def test_delete_project(client, mocker): @@ -118,5 +118,5 @@ def test_delete_project(client, mocker): }) mocker.patch.object(DB, 'update', return_value=None) mocker.patch.object(DB, 'delete_one', return_value={'googleId': 'test'}) - res = client.delete(f'/api/v2/projects/{test_id}') + res = client.delete(f'/v2/projects/{test_id}') assert '200' in res.status diff --git a/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py b/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py index 8ccebdad..71e88f00 100644 --- a/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py @@ -4,7 +4,7 @@ test_id = 24 * '1' def test_add_topology_missing_parameter(client): - assert '400' in client.post(f'/api/v2/projects/{test_id}/topologies').status + assert '400' in client.post(f'/v2/projects/{test_id}/topologies').status def test_add_topology(client, mocker): @@ -27,7 +27,7 @@ def test_add_topology(client, mocker): 'topologyIds': [] }) mocker.patch.object(DB, 'update', return_value={}) - res = client.post(f'/api/v2/projects/{test_id}/topologies', json={'topology': {'name': 'test project', 'rooms': []}}) + 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 @@ -43,7 +43,7 @@ def test_add_topology_not_authorized(client, mocker): 'authorizationLevel': 'VIEW' }] }) - assert '403' in client.post(f'/api/v2/projects/{test_id}/topologies', + assert '403' in client.post(f'/v2/projects/{test_id}/topologies', json={ 'topology': { 'name': 'test_topology', diff --git a/api/opendc/api/v2/projects/test_endpoint.py b/api/opendc/api/v2/projects/test_endpoint.py index cf02143c..9444b1e4 100644 --- a/api/opendc/api/v2/projects/test_endpoint.py +++ b/api/opendc/api/v2/projects/test_endpoint.py @@ -4,7 +4,7 @@ test_id = 24 * '1' def test_add_project_missing_parameter(client): - assert '400' in client.post('/api/v2/projects').status + assert '400' in client.post('/v2/projects').status def test_add_project(client, mocker): @@ -18,7 +18,7 @@ def test_add_project(client, mocker): 'topologyIds': [] }) mocker.patch.object(DB, 'update', return_value={}) - res = client.post('/api/v2/projects', json={'project': {'name': 'test project'}}) + res = client.post('/v2/projects', json={'project': {'name': 'test project'}}) assert 'datetimeCreated' in res.json['content'] assert 'datetimeLastEdited' in res.json['content'] assert 'topologyIds' in res.json['content'] diff --git a/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py b/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py index 386a9eea..cd4bcdf8 100644 --- a/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py +++ b/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py @@ -6,7 +6,7 @@ test_id_2 = 24 * '2' def test_get_scenario_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/scenarios/{test_id}').status + assert '404' in client.get(f'/v2/scenarios/{test_id}').status def test_get_scenario_no_authorizations(client, mocker): @@ -14,7 +14,7 @@ def test_get_scenario_no_authorizations(client, mocker): 'portfolioId': '1', 'authorizations': [] }) - res = client.get(f'/api/v2/scenarios/{test_id}') + res = client.get(f'/v2/scenarios/{test_id}') assert '403' in res.status @@ -30,7 +30,7 @@ def test_get_scenario_not_authorized(client, mocker): 'authorizationLevel': 'OWN' }] }) - res = client.get(f'/api/v2/scenarios/{test_id}') + res = client.get(f'/v2/scenarios/{test_id}') assert '403' in res.status @@ -46,17 +46,17 @@ def test_get_scenario(client, mocker): 'authorizationLevel': 'EDIT' }] }) - res = client.get(f'/api/v2/scenarios/{test_id}') + res = client.get(f'/v2/scenarios/{test_id}') assert '200' in res.status def test_update_scenario_missing_parameter(client): - assert '400' in client.put(f'/api/v2/scenarios/{test_id}').status + assert '400' in client.put(f'/v2/scenarios/{test_id}').status def test_update_scenario_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/scenarios/{test_id}', json={ + assert '404' in client.put(f'/v2/scenarios/{test_id}', json={ 'scenario': { 'name': 'test', } @@ -76,7 +76,7 @@ def test_update_scenario_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put(f'/api/v2/scenarios/{test_id}', json={ + assert '403' in client.put(f'/v2/scenarios/{test_id}', json={ 'scenario': { 'name': 'test', } @@ -101,7 +101,7 @@ def test_update_scenario(client, mocker): }) mocker.patch.object(DB, 'update', return_value={}) - res = client.put(f'/api/v2/scenarios/{test_id}', json={'scenario': { + res = client.put(f'/v2/scenarios/{test_id}', json={'scenario': { 'name': 'test', }}) assert '200' in res.status @@ -109,7 +109,7 @@ def test_update_scenario(client, mocker): def test_delete_project_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/scenarios/{test_id}').status + assert '404' in client.delete(f'/v2/scenarios/{test_id}').status def test_delete_project_different_user(client, mocker): @@ -126,7 +126,7 @@ def test_delete_project_different_user(client, mocker): }] }) mocker.patch.object(DB, 'delete_one', return_value=None) - assert '403' in client.delete(f'/api/v2/scenarios/{test_id}').status + assert '403' in client.delete(f'/v2/scenarios/{test_id}').status def test_delete_project(client, mocker): @@ -145,5 +145,5 @@ def test_delete_project(client, mocker): }) mocker.patch.object(DB, 'delete_one', return_value={}) mocker.patch.object(DB, 'update', return_value=None) - res = client.delete(f'/api/v2/scenarios/{test_id}') + res = client.delete(f'/v2/scenarios/{test_id}') assert '200' in res.status diff --git a/api/opendc/api/v2/schedulers/test_endpoint.py b/api/opendc/api/v2/schedulers/test_endpoint.py index a0bd8758..4950ca4c 100644 --- a/api/opendc/api/v2/schedulers/test_endpoint.py +++ b/api/opendc/api/v2/schedulers/test_endpoint.py @@ -1,2 +1,2 @@ def test_get_schedulers(client): - assert '200' in client.get('/api/v2/schedulers').status + assert '200' in client.get('/v2/schedulers').status diff --git a/api/opendc/api/v2/topologies/topologyId/test_endpoint.py b/api/opendc/api/v2/topologies/topologyId/test_endpoint.py index 76243ad6..4da0bc64 100644 --- a/api/opendc/api/v2/topologies/topologyId/test_endpoint.py +++ b/api/opendc/api/v2/topologies/topologyId/test_endpoint.py @@ -15,13 +15,13 @@ def test_get_topology(client, mocker): 'authorizationLevel': 'EDIT' }] }) - res = client.get(f'/api/v2/topologies/{test_id}') + res = client.get(f'/v2/topologies/{test_id}') 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 + assert '404' in client.get('/v2/topologies/1').status def test_get_topology_not_authorized(client, mocker): @@ -35,23 +35,23 @@ def test_get_topology_not_authorized(client, mocker): 'authorizationLevel': 'OWN' }] }) - res = client.get(f'/api/v2/topologies/{test_id}') + res = client.get(f'/v2/topologies/{test_id}') assert '403' in res.status def test_get_topology_no_authorizations(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'projectId': test_id, 'authorizations': []}) - res = client.get(f'/api/v2/topologies/{test_id}') + res = client.get(f'/v2/topologies/{test_id}') assert '403' in res.status def test_update_topology_missing_parameter(client): - assert '400' in client.put(f'/api/v2/topologies/{test_id}').status + assert '400' in client.put(f'/v2/topologies/{test_id}').status def test_update_topology_non_existent(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/topologies/{test_id}', json={'topology': {'name': 'test_topology', 'rooms': {}}}).status + assert '404' in client.put(f'/v2/topologies/{test_id}', json={'topology': {'name': 'test_topology', 'rooms': {}}}).status def test_update_topology_not_authorized(client, mocker): @@ -66,7 +66,7 @@ def test_update_topology_not_authorized(client, mocker): }] }) mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put(f'/api/v2/topologies/{test_id}', json={ + assert '403' in client.put(f'/v2/topologies/{test_id}', json={ 'topology': { 'name': 'updated_topology', 'rooms': {} @@ -87,7 +87,7 @@ def test_update_topology(client, mocker): }) mocker.patch.object(DB, 'update', return_value={}) - assert '200' in client.put(f'/api/v2/topologies/{test_id}', json={ + assert '200' in client.put(f'/v2/topologies/{test_id}', json={ 'topology': { 'name': 'updated_topology', 'rooms': {} @@ -110,10 +110,10 @@ def test_delete_topology(client, mocker): }) mocker.patch.object(DB, 'delete_one', return_value={}) mocker.patch.object(DB, 'update', return_value=None) - res = client.delete(f'/api/v2/topologies/{test_id}') + res = client.delete(f'/v2/topologies/{test_id}') assert '200' in res.status def test_delete_nonexistent_topology(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/topologies/{test_id}').status + assert '404' in client.delete(f'/v2/topologies/{test_id}').status diff --git a/api/opendc/api/v2/traces/test_endpoint.py b/api/opendc/api/v2/traces/test_endpoint.py index 9f806085..36846bd9 100644 --- a/api/opendc/api/v2/traces/test_endpoint.py +++ b/api/opendc/api/v2/traces/test_endpoint.py @@ -3,4 +3,4 @@ from opendc.util.database import DB def test_get_traces(client, mocker): mocker.patch.object(DB, 'fetch_all', return_value=[]) - assert '200' in client.get('/api/v2/traces').status + assert '200' in client.get('/v2/traces').status diff --git a/api/opendc/api/v2/traces/traceId/test_endpoint.py b/api/opendc/api/v2/traces/traceId/test_endpoint.py index 144f02bb..0c51538b 100644 --- a/api/opendc/api/v2/traces/traceId/test_endpoint.py +++ b/api/opendc/api/v2/traces/traceId/test_endpoint.py @@ -5,11 +5,11 @@ test_id = 24 * '1' def test_get_trace_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/traces/{test_id}').status + assert '404' in client.get(f'/v2/traces/{test_id}').status def test_get_trace(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'name': 'test trace'}) - res = client.get(f'/api/v2/traces/{test_id}') + res = client.get(f'/v2/traces/{test_id}') assert 'name' in res.json['content'] assert '200' in res.status diff --git a/api/opendc/api/v2/users/test_endpoint.py b/api/opendc/api/v2/users/test_endpoint.py index d60429b3..13b63b20 100644 --- a/api/opendc/api/v2/users/test_endpoint.py +++ b/api/opendc/api/v2/users/test_endpoint.py @@ -2,33 +2,33 @@ from opendc.util.database import DB def test_get_user_by_email_missing_parameter(client): - assert '400' in client.get('/api/v2/users').status + assert '400' in client.get('/v2/users').status def test_get_user_by_email_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get('/api/v2/users?email=test@test.com').status + assert '404' in client.get('/v2/users?email=test@test.com').status def test_get_user_by_email(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'email': 'test@test.com'}) - res = client.get('/api/v2/users?email=test@test.com') + res = client.get('/v2/users?email=test@test.com') assert 'email' in res.json['content'] assert '200' in res.status def test_add_user_missing_parameter(client): - assert '400' in client.post('/api/v2/users').status + assert '400' in client.post('/v2/users').status def test_add_user_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'email': 'test@test.com'}) - assert '409' in client.post('/api/v2/users', json={'user': {'email': 'test@test.com'}}).status + assert '409' in client.post('/v2/users', json={'user': {'email': 'test@test.com'}}).status def test_add_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) mocker.patch.object(DB, 'insert', return_value={'email': 'test@test.com'}) - res = client.post('/api/v2/users', json={'user': {'email': 'test@test.com'}}) + res = client.post('/v2/users', json={'user': {'email': 'test@test.com'}}) assert 'email' in res.json['content'] assert '200' in res.status diff --git a/api/opendc/api/v2/users/userId/test_endpoint.py b/api/opendc/api/v2/users/userId/test_endpoint.py index 89549f33..4085642f 100644 --- a/api/opendc/api/v2/users/userId/test_endpoint.py +++ b/api/opendc/api/v2/users/userId/test_endpoint.py @@ -5,52 +5,52 @@ test_id = 24 * '1' def test_get_user_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get(f'/api/v2/users/{test_id}').status + assert '404' in client.get(f'/v2/users/{test_id}').status def test_get_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'email': 'test@test.com'}) - res = client.get(f'/api/v2/users/{test_id}') + res = client.get(f'/v2/users/{test_id}') assert 'email' in res.json['content'] assert '200' in res.status def test_update_user_missing_parameter(client): - assert '400' in client.put(f'/api/v2/users/{test_id}').status + assert '400' in client.put(f'/v2/users/{test_id}').status def test_update_user_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put(f'/api/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}).status + assert '404' in client.put(f'/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}).status def test_update_user_different_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'_id': test_id, 'googleId': 'other_test'}) - assert '403' in client.put(f'/api/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}).status + assert '403' in client.put(f'/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}).status def test_update_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'_id': test_id, 'googleId': 'test'}) mocker.patch.object(DB, 'update', return_value={'givenName': 'A', 'familyName': 'B'}) - res = client.put(f'/api/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}) + res = client.put(f'/v2/users/{test_id}', json={'user': {'givenName': 'A', 'familyName': 'B'}}) assert 'givenName' in res.json['content'] assert '200' in res.status def test_delete_user_non_existing(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete(f'/api/v2/users/{test_id}').status + assert '404' in client.delete(f'/v2/users/{test_id}').status def test_delete_user_different_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'_id': test_id, 'googleId': 'other_test'}) - assert '403' in client.delete(f'/api/v2/users/{test_id}').status + assert '403' in client.delete(f'/v2/users/{test_id}').status def test_delete_user(client, mocker): mocker.patch.object(DB, 'fetch_one', return_value={'_id': test_id, 'googleId': 'test', 'authorizations': []}) mocker.patch.object(DB, 'delete_one', return_value={'googleId': 'test'}) - res = client.delete(f'/api/v2/users/{test_id}', ) + res = client.delete(f'/v2/users/{test_id}', ) assert 'googleId' in res.json['content'] assert '200' in res.status |
