def test_login_with_success(): api.signup('*****@*****.**', 'ana123') response = api.login('*****@*****.**', 'ana123') assert response.status_code == 200 assert 'token' in response.json()
def access_token(): email = '*****@*****.**' password = '******' auth_api.signup(email, password) response = auth_api.login(email, password) return response.json()['token']
def test_login_with_invalid_password(): api.signup('*****@*****.**', 'marcia123') response = api.login('*****@*****.**', 'm@rcia123') expected_response = { 'code': 'AUTHENTICATION_FAILED', 'message': 'Wrong email or password', } assert response.status_code == 401 assert response.json() == expected_response
def test_signup_with_email_already_registered(): email = '*****@*****.**' api.signup(email, 'monica') response = api.signup(email, 'monica') expected_response = { 'code': 'EMAIL_ALREADY_REGISTERED', 'message': f'Email "{email}" already registered', } assert response.status_code == 422 assert response.json() == expected_response
def test_signup_with_success(): response = api.signup('*****@*****.**', 'jonas') expected_response = {'message': 'User registered with success'} assert response.status_code == 201 assert response.json() == expected_response
def test_signup_with_invalid_email(): response = api.signup('jonas@gmailcom', 'jonas') expected_response = { 'code': 'VALIDATION_ERROR', 'errors': { 'email': ['Not a valid email address.'] }, 'message': 'Validation error', } assert response.status_code == 422 assert response.json() == expected_response