1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-29 07:54:19 +00:00

completati i controlli sulle condition

This commit is contained in:
stefanogoldoni 2021-05-02 23:02:25 +02:00
parent 1d6e393185
commit 758779d05a

View file

@ -1,37 +1,40 @@
import json
import unittest import unittest
import requests import requests
import json
from database.tables.Enums import ConditionType
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def test_repository_condition(self): def test_repository_condition(self):
# entro come user e recupero le informazioni sulla repo specificata # 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) j = json.loads(r.text)
assert j['result'] == "success" assert j['result'] == "success"
auth_code = j['data']['access_token'] auth_code = j['data']['access_token']
r = requests.get(f'http://localhost:5000/api/v1/repositories/1/conditions', headers={'authorization': "Bearer " + auth_code}) r = requests.get(f'http://localhost:5000/api/v1/repositories/16/conditions',
j = json.loads(r.text) # INTERNAL SERVER ERROR status code 500 headers={'authorization': "Bearer " + auth_code})
j = json.loads(r.text)
assert j['result'] == "success" assert j['result'] == "success"
print("Conditions dei Repositories letti correttamente!")
# entro come user ed aggiungo una condition alla repo specificata # 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) j = json.loads(r.text)
assert j['result'] == "success" assert j['result'] == "success"
auth_code = j['data']['access_token'] auth_code = j['data']['access_token']
r = requests.post(f'http://localhost:5000/api/v1/repositories/1/conditions', headers={'authorization': "Bearer " + auth_code}, r = requests.post(f'http://localhost:5000/api/v1/repositories/16/conditions',
json={'type': 'hashtag', 'content': 'MarioDraghi'}) headers={'authorization': "Bearer " + auth_code},
j = json.loads(r.text) # BAD REQUEST erroe 400 json={'type': 0, 'content': 'MarioDraghi'})
assert j['result'] == "failure" j = json.loads(r.text)
assert j['result'] == "success"
for i in j: print("Conditions dei Repositories creati correttamente!")
print(j[i])
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
print('Testing dei metodi di modifica delle conditions')