From 11ab4143bb80bfe65dff4dc65247ce2e1ca2836d Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Fri, 30 Apr 2021 22:21:12 +0200 Subject: [PATCH] lettura e creazione repository testata in tutti i metodi --- .../nest_backend/test/repositories_test.py | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/code/backend/nest_backend/test/repositories_test.py b/code/backend/nest_backend/test/repositories_test.py index 70945c1..4057357 100644 --- a/code/backend/nest_backend/test/repositories_test.py +++ b/code/backend/nest_backend/test/repositories_test.py @@ -9,19 +9,12 @@ auth_code = "" class MyTestCase(unittest.TestCase): def test_repository_create(self): global auth_code - # TEST IN POST + # entro come utente_Test r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'utente_test@nest.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/v1/repositories/', headers={'authorization': "Bearer " + auth_code}, - json={}) - j = json.loads(r.text) - assert j['result'] == "success" - - print("Repository creata correttamente!") - # TEST IN GET r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'utente_test@nest.com', 'password': 'password'}) j = json.loads(r.text) @@ -35,7 +28,31 @@ class MyTestCase(unittest.TestCase): for i in j: print(j[i]) + print("Repositories letti correttamente!") + + # TODO: testare anche i parametri onlyDead e onlyActive + + # creo un repo senza nome: fallisce + r = requests.post(f'http://localhost:5000/api/v1/repositories/', headers={'authorization': "Bearer " + auth_code}, + json={}) + j = json.loads(r.text) + assert j['result'] == "failure" + + # creo un repo con nome vuoto: fallisce + r = requests.post(f'http://localhost:5000/api/v1/repositories/', headers={'authorization': "Bearer " + auth_code}, + json={'nome': ''}) + j = json.loads(r.text) + assert j['result'] == "failure" + + # creo un repo: successo + r = requests.post(f'http://localhost:5000/api/v1/repositories/', headers={'authorization': "Bearer " + auth_code}, + json={'name': 'repo_test_2'}) + j = json.loads(r.text) + assert j['result'] == "success" + + print("Repository creata correttamente!") -print("Testing del metodo repository_create") + +print("Testing dei metodi di lettura e creazione repository")