示例#1
0
def test_login_with_success():
    api.signup('*****@*****.**', 'ana123')

    response = api.login('*****@*****.**', 'ana123')

    assert response.status_code == 200
    assert 'token' in response.json()
示例#2
0
def access_token():
    email = '*****@*****.**'
    password = '******'

    auth_api.signup(email, password)
    response = auth_api.login(email, password)
    return response.json()['token']
示例#3
0
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
示例#4
0
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
示例#5
0
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
示例#6
0
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