From 22303cb85a98deeb888f79d80912db85c1b94545 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <256895@studenti.unimore.it> Date: Sat, 8 May 2021 00:38:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Merge=20tests=20in=20a=20single?= =?UTF-8?q?=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/backend/nest_backend/test/test_user.py | 20 +++++++++++++++++++ .../nest_backend/test/test_user_add.py | 9 --------- .../nest_backend/test/test_user_delete.py | 8 -------- .../nest_backend/test/test_user_get.py | 9 --------- 4 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 code/backend/nest_backend/test/test_user.py delete mode 100644 code/backend/nest_backend/test/test_user_add.py delete mode 100644 code/backend/nest_backend/test/test_user_delete.py delete mode 100644 code/backend/nest_backend/test/test_user_get.py diff --git a/code/backend/nest_backend/test/test_user.py b/code/backend/nest_backend/test/test_user.py new file mode 100644 index 0000000..bc94398 --- /dev/null +++ b/code/backend/nest_backend/test/test_user.py @@ -0,0 +1,20 @@ +from flask.testing import Client + + +class TestUserGet: + def test_for_success(self, flask_client: Client, access_token: str): + r = flask_client.get(f'/api/v1/users/admin@admin.com', headers={'Authorization': f"Bearer {access_token}"}) + assert b'success' in r.data + + +class TestUserAdd: + def test_for_success(self, flask_client: Client, access_token: str): + r = flask_client.post(f'/api/v1/users/', headers={'Authorization': f"Bearer {access_token}"}, + json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente_test'}) + assert b'success' in r.data + + +class TestUserDelete: + def test_for_success(self, flask_client: Client, access_token: str): + r = flask_client.delete(f'/api/v1/users/utente_test@nest.com', headers={'Authorization': f"Bearer {access_token}"}) + assert b'success' in r.data diff --git a/code/backend/nest_backend/test/test_user_add.py b/code/backend/nest_backend/test/test_user_add.py deleted file mode 100644 index f533b9d..0000000 --- a/code/backend/nest_backend/test/test_user_add.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask.testing import Client - -# test add user utente_test - - -def test_user_add(flask_client: Client, access_token: str): - r = flask_client.post(f'/api/v1/users/', headers={'Authorization': f"Bearer {access_token}"}, - json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente_test'}) - assert b'success' in r.data diff --git a/code/backend/nest_backend/test/test_user_delete.py b/code/backend/nest_backend/test/test_user_delete.py deleted file mode 100644 index 0117bdc..0000000 --- a/code/backend/nest_backend/test/test_user_delete.py +++ /dev/null @@ -1,8 +0,0 @@ -from flask.testing import Client - -# test delete user utente_test - - -def test_user_delete(flask_client: Client, access_token: str): - r = flask_client.delete(f'/api/v1/users/utente_test@nest.com', headers={'Authorization': f"Bearer {access_token}"}) - assert b'success' in r.data diff --git a/code/backend/nest_backend/test/test_user_get.py b/code/backend/nest_backend/test/test_user_get.py deleted file mode 100644 index ec670f0..0000000 --- a/code/backend/nest_backend/test/test_user_get.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask.testing import Client - -# test get user admin - - -def test_user_get(flask_client: Client, access_token: str): - r = flask_client.get(f'/api/v1/users/admin@admin.com', headers={'Authorization': f"Bearer {access_token}"}) - assert b'success' in r.data -