fix tests
This commit is contained in:
parent
1126ff1321
commit
2ede168518
20
tests/api.py
20
tests/api.py
@ -1,6 +1,13 @@
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from locust import HttpUser, FastHttpUser
|
import requests
|
||||||
|
|
||||||
|
class Requests():
|
||||||
|
def __init__(self, baseUrl):
|
||||||
|
self.baseUrl = baseUrl
|
||||||
|
|
||||||
|
def post(self, path, json = {}):
|
||||||
|
return requests.post(self.baseUrl + path, json=json)
|
||||||
|
|
||||||
class Auth():
|
class Auth():
|
||||||
token: string
|
token: string
|
||||||
@ -47,14 +54,19 @@ class BackendApi():
|
|||||||
response = self.httpClient.post(
|
response = self.httpClient.post(
|
||||||
"/v1/user/login",
|
"/v1/user/login",
|
||||||
json={
|
json={
|
||||||
"email": user.email,
|
"email": user.email+"a",
|
||||||
"password": user.password,
|
"password": user.password,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
status = response.json()['status']
|
||||||
|
if status == 'error':
|
||||||
|
raise AssertionError(response.json()['error']['message'])
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise AssertionError('can not login user')
|
raise AssertionError('can not login user')
|
||||||
|
|
||||||
token = response.json()['token']
|
token = response.json()['result']['token']
|
||||||
if token == '':
|
if token == '':
|
||||||
raise AssertionError('empty user token')
|
raise AssertionError('empty user token')
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
from api import BackendApi
|
from api import BackendApi, Requests
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
backendUrl = "http://localhost:8080"
|
||||||
|
|
||||||
class TestUser:
|
class TestUser:
|
||||||
def test_create_user(self):
|
def test_create_user(self):
|
||||||
api = BackendApi(requests)
|
api = BackendApi(Requests(backendUrl))
|
||||||
api.user_create()
|
api.user_create()
|
||||||
|
|
||||||
def test_login_user(self):
|
def test_login_user(self):
|
||||||
api = BackendApi(requests)
|
api = BackendApi(Requests(backendUrl))
|
||||||
user = api.user_create()
|
user = api.user_create()
|
||||||
api.user_login(user)
|
api.user_login(user)
|
||||||
@ -15,7 +15,10 @@ install:
|
|||||||
requirements:
|
requirements:
|
||||||
pip freeze > requirements.txt
|
pip freeze > requirements.txt
|
||||||
|
|
||||||
run-web:
|
run-integration:
|
||||||
|
python3 -m pytest integration/
|
||||||
|
|
||||||
|
run-performance-web:
|
||||||
locust -f performance --class-picker --host http://localhost:8080 --processes 16
|
locust -f performance --class-picker --host http://localhost:8080 --processes 16
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user