From eae6e3eb17a683d4366108cde58dcf8776bd7017 Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Mon, 26 Apr 2021 23:19:17 +0200 Subject: [PATCH] aggiunto verifica creazione utente --- .../nest_backend/test/user_create_test.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 code/backend/nest_backend/test/user_create_test.py diff --git a/code/backend/nest_backend/test/user_create_test.py b/code/backend/nest_backend/test/user_create_test.py new file mode 100644 index 0000000..0ddf2ad --- /dev/null +++ b/code/backend/nest_backend/test/user_create_test.py @@ -0,0 +1,25 @@ +import requests +import json + +auth_code = "" + + +def test_user_create(): + global auth_code + + r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'}) + j = json.loads(r.text) + assert j['result'] == "success" + auth_code = j['data']['access_token'] + + r = requests.post(f'http://localhost:5000/api/user/create', headers={'authorization': "Bearer " + auth_code}, + json={'email': 'utente5@nest.com', 'password': '1234', 'username': 'utente5'}) + j = json.loads(r.text) + assert j['result'] == "success" + + auth_code = j['data']['access_token'] + print("User_create eseguito correttamente!") + + +print("Testing del metodo user_create") +test_user_create()