From 1a23d9c81f96b923b5fe08094e6fb192573942d0 Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Tue, 25 May 2021 10:41:59 +0200 Subject: [PATCH] Tests work properly lets gooooo --- nest_backend/test/test_2_repository.py | 1 + nest_backend/test/test_3_condition.py | 14 +++++++------- nest_backend/test/test_4_alert.py | 6 +++--- nest_backend/test/test_5_authorizations.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/nest_backend/test/test_2_repository.py b/nest_backend/test/test_2_repository.py index 0f282fd..7b9a86e 100644 --- a/nest_backend/test/test_2_repository.py +++ b/nest_backend/test/test_2_repository.py @@ -245,6 +245,7 @@ class TestRepositoryPut: "isAdmin": True, "username": "string" }, + "spectators": [], "start": "2021-05-14T12:12:29.827Z" }) assert r.status_code == 200 diff --git a/nest_backend/test/test_3_condition.py b/nest_backend/test/test_3_condition.py index 6657e98..fb621e1 100644 --- a/nest_backend/test/test_3_condition.py +++ b/nest_backend/test/test_3_condition.py @@ -8,42 +8,42 @@ from flask.testing import Client class TestConditionGetAllOfARepository: def test_repository_not_found(self, flask_client: Client, user_headers): - r = flask_client.get(f'/api/v1/repositories/99/conditions', headers=user_headers) + r = flask_client.get(f'/api/v1/repositories/99/conditions/', headers=user_headers) assert r.status_code == 404 assert r.json["result"] == "failure" def test__unauthorized_repository(self, flask_client: Client, admin_headers): - r = flask_client.get(f'/api/v1/repositories/1/conditions', headers=admin_headers) + r = flask_client.get(f'/api/v1/repositories/1/conditions/', headers=admin_headers) assert r.status_code == 403 assert r.json["result"] == "failure" def test_get_all_conditions_of_a_repository(self, flask_client: Client, user_headers): - r = flask_client.get(f'/api/v1/repositories/1/conditions', headers=user_headers) + r = flask_client.get(f'/api/v1/repositories/1/conditions/', headers=user_headers) assert r.status_code == 200 assert r.json["result"] == "success" class TestConditionPost: def test_missing_type(self, flask_client: Client, user_headers): - r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, + r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers, json={}) assert r.status_code == 400 assert r.json["result"] == "failure" def test_wrong_type(self, flask_client: Client, user_headers): - r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, + r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers, json={"content": "string", "type": 99}) assert r.status_code == 400 assert r.json["result"] == "failure" def test_missing_content(self, flask_client: Client, user_headers): - r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, + r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers, json={"type": 0}) assert r.status_code == 400 assert r.json["result"] == "failure" def test_for_success(self, flask_client: Client, user_headers): - r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers, + r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers, json={"content": "onlyForTest", "type": 0}) assert r.status_code == 201 assert r.json["result"] == "success" diff --git a/nest_backend/test/test_4_alert.py b/nest_backend/test/test_4_alert.py index e28deb4..4307fea 100644 --- a/nest_backend/test/test_4_alert.py +++ b/nest_backend/test/test_4_alert.py @@ -8,17 +8,17 @@ from flask.testing import Client class TestAlertsGetAllOfARepository: def test_repository_not_found(self, flask_client: Client, user_headers): - r = flask_client.get(f'/api/v1/repositories/99/alerts', headers=user_headers) + r = flask_client.get(f'/api/v1/repositories/99/alerts/', headers=user_headers) assert r.status_code == 404 assert r.json["result"] == "failure" def test_unauthorized_repository(self, flask_client: Client, admin_headers): - r = flask_client.get(f'/api/v1/repositories/1/alerts', headers=admin_headers) + r = flask_client.get(f'/api/v1/repositories/1/alerts/', headers=admin_headers) assert r.status_code == 403 assert r.json["result"] == "failure" def test_get_all_alerts_of_a_repository(self, flask_client: Client, user_headers): - r = flask_client.get(f'/api/v1/repositories/1/alerts', headers=user_headers) + r = flask_client.get(f'/api/v1/repositories/1/alerts/', headers=user_headers) assert r.status_code == 200 assert r.json["result"] == "success" diff --git a/nest_backend/test/test_5_authorizations.py b/nest_backend/test/test_5_authorizations.py index ea8afac..8ac2824 100644 --- a/nest_backend/test/test_5_authorizations.py +++ b/nest_backend/test/test_5_authorizations.py @@ -47,7 +47,7 @@ class TestAuthorizationsPut: r = flask_client.put(f'/api/v1/repositories/1/authorizations/', headers=user_headers, json={ 'email': 'admin@admin.com' }) - assert r.status_code == 201 + assert r.status_code == 200 assert r.json["result"] == "success" def test_authorization_already_existed(self, flask_client: Client, user_headers):