From 758779d05a131515104bdb52de7b2ba573679e48 Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Sun, 2 May 2021 23:02:25 +0200 Subject: [PATCH] completati i controlli sulle condition --- .../test/repository_conditions_test.py | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/code/backend/nest_backend/test/repository_conditions_test.py b/code/backend/nest_backend/test/repository_conditions_test.py index 73504d6..dc084bb 100644 --- a/code/backend/nest_backend/test/repository_conditions_test.py +++ b/code/backend/nest_backend/test/repository_conditions_test.py @@ -1,37 +1,40 @@ -import json import unittest - import requests +import json +from database.tables.Enums import ConditionType class MyTestCase(unittest.TestCase): def test_repository_condition(self): - # entro come user e recupero le informazioni sulla repo specificata - r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'utente_test@nest.com', 'password': 'password'}) + 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.get(f'http://localhost:5000/api/v1/repositories/1/conditions', headers={'authorization': "Bearer " + auth_code}) - j = json.loads(r.text) # INTERNAL SERVER ERROR status code 500 + r = requests.get(f'http://localhost:5000/api/v1/repositories/16/conditions', + headers={'authorization': "Bearer " + auth_code}) + j = json.loads(r.text) assert j['result'] == "success" + print("Conditions dei Repositories letti correttamente!") # entro come user ed aggiungo una condition alla repo specificata - r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'utente_test@nest.com', 'password': 'password'}) + 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/1/conditions', headers={'authorization': "Bearer " + auth_code}, - json={'type': 'hashtag', 'content': 'MarioDraghi'}) - j = json.loads(r.text) # BAD REQUEST erroe 400 - assert j['result'] == "failure" - - for i in j: - print(j[i]) + r = requests.post(f'http://localhost:5000/api/v1/repositories/16/conditions', + headers={'authorization': "Bearer " + auth_code}, + json={'type': 0, 'content': 'MarioDraghi'}) + j = json.loads(r.text) + assert j['result'] == "success" + print("Conditions dei Repositories creati correttamente!") if __name__ == '__main__': unittest.main() +print('Testing dei metodi di modifica delle conditions')