2020-05-03 00:45:45 +02:00
|
|
|
from secrets import token_hex
|
|
|
|
|
2020-09-11 00:07:45 +02:00
|
|
|
from app.schemas import *
|
2020-09-28 18:19:59 +02:00
|
|
|
from database.models import *
|
2020-09-11 00:07:45 +02:00
|
|
|
from tests import client
|
2020-09-28 18:19:59 +02:00
|
|
|
from tests.queries_test import get_test_db
|
2020-05-03 00:45:45 +02:00
|
|
|
|
2020-09-11 00:07:45 +02:00
|
|
|
|
|
|
|
def test_registration():
|
2020-05-03 00:45:45 +02:00
|
|
|
user = {
|
|
|
|
"full_name": "Bilal Balaperdida",
|
|
|
|
"email": "oyvey@hotmail.com",
|
2020-05-28 00:53:23 +02:00
|
|
|
"password": "lifeisabitch",
|
2020-09-11 00:07:45 +02:00
|
|
|
"gender": 1,
|
2020-05-03 00:45:45 +02:00
|
|
|
"mobile": "+212655778899",
|
|
|
|
"user_type": 1,
|
|
|
|
"lang_type": 1,
|
|
|
|
"device_type": 1,
|
2020-09-11 00:07:45 +02:00
|
|
|
"device_id": token_hex(16),
|
|
|
|
"city_id": 5,
|
2020-05-03 00:45:45 +02:00
|
|
|
}
|
|
|
|
response = client.post("/register", json=user)
|
2020-09-11 00:07:45 +02:00
|
|
|
assert response.status_code == 200
|
2020-05-28 00:53:23 +02:00
|
|
|
|
|
|
|
|
2020-09-28 18:19:59 +02:00
|
|
|
def test_otp_verification(get_test_db):
|
|
|
|
user = get_test_db.query(Users).filter(Users.email == "oyvey@hotmail.com").first()
|
2020-10-08 20:47:10 +02:00
|
|
|
data = {"access_key": user.access_key, "otp": user.otp}
|
2020-09-28 18:19:59 +02:00
|
|
|
response = client.post("/otpVerification", json=data)
|
|
|
|
assert response.status_code == 200
|
2020-09-28 18:46:44 +02:00
|
|
|
|
|
|
|
|
2020-10-05 15:35:13 +02:00
|
|
|
def test_login():
|
|
|
|
user = {
|
|
|
|
"email": "testorganizer@odyfo.com",
|
|
|
|
"password": "odyfo2020",
|
|
|
|
"device_id": "0",
|
|
|
|
"lang_type": 1,
|
|
|
|
"user_type": 2,
|
|
|
|
}
|
|
|
|
response = client.post("/login", json=user)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
2020-09-28 18:46:44 +02:00
|
|
|
def test_resend_otp():
|
2020-10-08 20:47:10 +02:00
|
|
|
data = {"email": "testorganizer@odyfo.com"}
|
2020-09-28 18:46:44 +02:00
|
|
|
response = client.post("/resendOTP", json=data)
|
|
|
|
assert response.status_code == 200
|
2020-10-08 20:47:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_forgot_password():
|
|
|
|
data = {"email": "oyvey@hotmail.com"}
|
|
|
|
response = client.post("/forgot_password", json=data)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|