From 75dc9f1c902d2b49a483ecbaf36ce146f839bb43 Mon Sep 17 00:00:00 2001 From: Annielated Date: Sat, 1 May 2021 18:17:24 +0200 Subject: [PATCH] test per l'aggiunta di condizioni ad una repository, attualmente non funzionante, errore 500 quando si richiedono info sulla repo e 400 quando si aggiunge una condition, da risolvere --- .../test/repository_conditions_test.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 code/backend/nest_backend/test/repository_conditions_test.py diff --git a/code/backend/nest_backend/test/repository_conditions_test.py b/code/backend/nest_backend/test/repository_conditions_test.py new file mode 100644 index 0000000..9625127 --- /dev/null +++ b/code/backend/nest_backend/test/repository_conditions_test.py @@ -0,0 +1,36 @@ +import unittest +import requests +import json + + +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'}) + 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 + assert j['result'] == "success" + + + # 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'}) + 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]) + + +if __name__ == '__main__': + unittest.main()