From ef6852037cc52db1f117dc5e8646fb10f505abeb Mon Sep 17 00:00:00 2001 From: FlaviaC-uni <80752618+FlaviaC-uni@users.noreply.github.com> Date: Sat, 8 May 2021 18:00:53 +0200 Subject: [PATCH] aggiunti vari test --- code/backend/nest_backend/test/test_user.py | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/code/backend/nest_backend/test/test_user.py b/code/backend/nest_backend/test/test_user.py index ef23b9a..69544d4 100644 --- a/code/backend/nest_backend/test/test_user.py +++ b/code/backend/nest_backend/test/test_user.py @@ -9,12 +9,30 @@ class TestUserGet: class TestUserAdd: def test_for_success(self, flask_client: Client, admin_headers): - r = flask_client.post(f'/api/v1/users/', headers=admin_headers, - json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente_test'}) + r = flask_client.post(f'/api/v1/users/', headers=admin_headers, json={ + 'email': 'utente_test@nest.com', + 'password': 'password', + 'username': 'utente_test' + }) assert b'success' in r.data + def test_for_failure(self, flask_client: Client, user_headers): + r = flask_client.post(f'/api/v1/users/', headers=user_headers, json={ + 'email': 'utente_test@nest.com', + 'password': 'password', + 'username': 'utente_test' + }) + assert b'failure' in r.data + class TestUserDelete: def test_for_success(self, flask_client: Client, admin_headers): r = flask_client.delete(f'/api/v1/users/utente_test@nest.com', headers=admin_headers) assert b'success' in r.data + + # the admin tries to commit suicide + def test_for_failure(self, flask_client: Client, admin_headers): + r = flask_client.delete(f'/api/v1/users/admin@admin.com', headers=admin_headers) + assert b'failure' in r.data + +