Ejemplo n.º 1
0
def user(run, db):
    data = SignUpSchema(email='*****@*****.**',
                        username='******',
                        first_name='Test',
                        last_name='Test',
                        password='******')
    response = run(signup(data, db))
    assert ResponseSchema(**response).message == messages['signup_success']
    login_data = LogInSchema(username='******', password='******')
    login_response = run(login(login_data, db))
    assert LogInResponseSchema(
        **login_response).user.username == login_data.username
    return LogInResponseSchema(**login_response).user
Ejemplo n.º 2
0
def test_login(run, db):
    data = LogInSchema(username='******', password='******')
    response = run(login(data, db))
    assert 'token' in LogInResponseSchema(**response).token.dict().keys()
    assert LogInResponseSchema(**response).user.username == data.username
Ejemplo n.º 3
0
def test_login_with_invalid_password(run, db):
    data = LogInSchema(username='******', password='******')
    with pytest.raises(HTTPException) as error:
        run(login(data, db))
    assert error.value.status_code == HTTP_401_UNAUTHORIZED
Ejemplo n.º 4
0
def test_login_with_invalid_email(run, db):
    data = LogInSchema(username='******', password='******')
    with pytest.raises(HTTPException) as error:
        run(login(data, db))
    assert error.value.status_code == HTTP_404_NOT_FOUND