1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-23 05:24:18 +00:00
pds-2021-g2-nest/legacy/tests/repository_test.py

38 lines
1.3 KiB
Python
Raw Normal View History

import json
import unittest
import requests
class MyTestCase(unittest.TestCase):
def test_repository_edit(self):
global auth_code
# eseguo il login
2021-05-02 15:59:02 +00:00
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']
2021-05-02 16:03:19 +00:00
# ritorno le info sulla repository speficicata
r = requests.get(f'http://localhost:5000/api/v1/repositories/1', headers={'authorization': "Bearer " + auth_code})
j = json.loads(r.text)
assert j['result'] == "success"
2021-05-02 16:03:19 +00:00
# cancello la repository specificata
r = requests.delete(f'http://localhost:5000/api/v1/repositories/1', headers={'authorization': "Bearer " + auth_code})
j = json.loads(r.text)
2021-05-02 16:03:19 +00:00
assert j['result'] == "success"
2021-05-02 16:03:19 +00:00
# modifico il nome e lo stato della repository specificata
r = requests.patch(f'http://localhost:5000/api/v1/repositories/1', headers={'authorization': "Bearer " + auth_code},
2021-05-02 15:59:02 +00:00
json={'name': 'newname', 'open': True})
j = json.loads(r.text)
assert j['result'] == "success"
print('Testing del metodo repository_edit')