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 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():
|
||||
token: string
|
||||
@ -47,14 +54,19 @@ class BackendApi():
|
||||
response = self.httpClient.post(
|
||||
"/v1/user/login",
|
||||
json={
|
||||
"email": user.email,
|
||||
"email": user.email+"a",
|
||||
"password": user.password,
|
||||
},
|
||||
)
|
||||
|
||||
status = response.json()['status']
|
||||
if status == 'error':
|
||||
raise AssertionError(response.json()['error']['message'])
|
||||
|
||||
if response.status_code != 200:
|
||||
raise AssertionError('can not login user')
|
||||
|
||||
token = response.json()['token']
|
||||
|
||||
token = response.json()['result']['token']
|
||||
if token == '':
|
||||
raise AssertionError('empty user token')
|
||||
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
from api import BackendApi
|
||||
from api import BackendApi, Requests
|
||||
import requests
|
||||
|
||||
backendUrl = "http://localhost:8080"
|
||||
|
||||
class TestUser:
|
||||
def test_create_user(self):
|
||||
api = BackendApi(requests)
|
||||
api = BackendApi(Requests(backendUrl))
|
||||
api.user_create()
|
||||
|
||||
def test_login_user(self):
|
||||
api = BackendApi(requests)
|
||||
api = BackendApi(Requests(backendUrl))
|
||||
user = api.user_create()
|
||||
api.user_login(user)
|
||||
@ -15,7 +15,10 @@ install:
|
||||
requirements:
|
||||
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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user