1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 22:44:19 +00:00

importato unittest, rimossa chiamata della funzione che ora avviene grazie al parametro self

This commit is contained in:
Annielated 2021-04-28 19:55:59 +02:00
parent 9ea852b50b
commit aaab6094a9
3 changed files with 27 additions and 18 deletions

View file

@ -1,10 +1,13 @@
import unittest
import requests import requests
import json import json
auth_code = "" auth_code = ""
def test_user_create(): class MyTestCase(unittest.TestCase):
def test_user_create(self):
global auth_code global auth_code
r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'}) r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'})
@ -13,7 +16,7 @@ def test_user_create():
auth_code = j['data']['access_token'] auth_code = j['data']['access_token']
r = requests.post(f'http://localhost:5000/api/user/create', headers={'authorization': "Bearer " + auth_code}, r = requests.post(f'http://localhost:5000/api/user/create', headers={'authorization': "Bearer " + auth_code},
json={'email': 'utente12@nest.com', 'password': '1234', 'username': 'utente12'}) json={'email': 'utente16@nest.com', 'password': '', 'username': 'utente16'})
j = json.loads(r.text) j = json.loads(r.text)
assert j['result'] == "success" assert j['result'] == "success"
@ -21,4 +24,8 @@ def test_user_create():
print("Testing del metodo user_create") print("Testing del metodo user_create")
test_user_create()
if __name__ == '__main__':
unittest.main()

View file

@ -1,10 +1,12 @@
import requests import requests
import json import json
import unittest
auth_code = "" auth_code = ""
def test_user_delete(): class MyTestCase(unittest.TestCase):
def test_user_delete(self):
global auth_code global auth_code
r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'}) r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'})
@ -13,12 +15,12 @@ def test_user_delete():
auth_code = j['data']['access_token'] auth_code = j['data']['access_token']
r = requests.post(f'http://localhost:5000/api/user/remove', headers={'authorization': "Bearer " + auth_code}, r = requests.post(f'http://localhost:5000/api/user/remove', headers={'authorization': "Bearer " + auth_code},
json={'email': 'utente10@nest.com'}) json={'email': 'utente15@nest.com'})
j = json.loads(r.text) j = json.loads(r.text)
assert j['result'] == "success" assert j['result'] == "success"
print("User_delete eseguito correttamente!") print("User_delete eseguito correttamente!")
print("Testing del metodo user_delete")
print("Testing del metodo user_delete")
test_user_delete()