From 8c5cb1735c0e02220ba40e56d289cebc4442150c Mon Sep 17 00:00:00 2001 From: Annielated Date: Wed, 28 Apr 2021 23:14:21 +0200 Subject: [PATCH] importato unittest, rimossa chiamata della funzione che ora avviene grazie al parametro self --- code/backend/nest_backend/test/login_test.py | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/code/backend/nest_backend/test/login_test.py b/code/backend/nest_backend/test/login_test.py index 998d91b..27a8758 100644 --- a/code/backend/nest_backend/test/login_test.py +++ b/code/backend/nest_backend/test/login_test.py @@ -1,23 +1,25 @@ +import unittest import requests import json auth_code = "" -def test_login(): - global auth_code - r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'amogus'}) - j = json.loads(r.text) - assert j['result'] == "failure" - r = requests.post('http://localhost:5000/api/login', json={'email': '', 'password': ''}) - j = json.loads(r.text) - assert j['result'] == "failure" - 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'] - print("Login eseguito correttamente!") +class MyTestCase(unittest.TestCase): + def test_login(self): + global auth_code + r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'amogus'}) + j = json.loads(r.text) + assert j['result'] == "failure" + r = requests.post('http://localhost:5000/api/login', json={'email': '', 'password': ''}) + j = json.loads(r.text) + assert j['result'] == "failure" + 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'] + print("Login eseguito correttamente!") print("Testing del login") -test_login() +