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
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
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
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