mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-23 05:24:18 +00:00
31 lines
807 B
Python
31 lines
807 B
Python
import unittest
|
|
import requests
|
|
import json
|
|
|
|
|
|
auth_code = ""
|
|
|
|
|
|
class MyTestCase(unittest.TestCase):
|
|
def test_user_create(self):
|
|
global auth_code
|
|
|
|
r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.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/user/create', headers={'authorization': "Bearer " + auth_code},
|
|
json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente'})
|
|
j = json.loads(r.text)
|
|
assert j['result'] == "success"
|
|
|
|
print("User_create eseguito correttamente!")
|
|
|
|
|
|
print("Testing del metodo user_create")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
|