Esempio n. 1
0
def test_update_email_same_twice(user_1):
    """Setting the email that the user already has raises an error.
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    with pytest.raises(InputError):
        user.user_profile_setemail(user_1['token'], '*****@*****.**')
    clear()
Esempio n. 2
0
def test_email_varying_domain(user_1):
    """Test for a domain other than @gmail.com
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    user_details = user.user_profile(user_1['token'], user_1['u_id'])

    assert '*****@*****.**' in user_details['user']['email']
    clear()
Esempio n. 3
0
def test_valid_email(user_1):
    """Test for basic functionality for updating user email.
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    user_details = user.user_profile(user_1['token'], user_1['u_id'])

    assert '*****@*****.**' in user_details['user']['email']
    clear()
Esempio n. 4
0
def test_email_min_requirements(user_1):
    """Test for an email with very minimal requirements (2 letters in the personal
    part, a '@' symbol, at least 1 letter before and after the period in the domain).
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    user_details = user.user_profile(user_1['token'], user_1['u_id'])

    assert '*****@*****.**' in user_details['user']['email']
    clear()
Esempio n. 5
0
def test_update_email(user_1):
    """Basic test for updating email twice and checking if the current email is the
    last set.
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    user_details = user.user_profile(user_1['token'], user_1['u_id'])

    assert '*****@*****.**' in user_details['user']['email']
    clear()
Esempio n. 6
0
def test_multiple_update_email(user_1):
    """Test for multiple attempts at updating a user email.
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')
    user.user_profile_setemail(user_1['token'], '*****@*****.**')
    user.user_profile_setemail(user_1['token'], '*****@*****.**')
    user.user_profile_setemail(user_1['token'], '*****@*****.**')

    user_details = user.user_profile(user_1['token'], user_1['u_id'])

    assert '*****@*****.**' in user_details['user']['email']
    clear()
Esempio n. 7
0
def test_email_already_in_use(user_1, user_2, user_3):
    """Test for an email that is already in use by another active user.
    """
    user.user_profile_setemail(user_1['token'], '*****@*****.**')
    user.user_profile_setemail(user_3['token'], '*****@*****.**')

    with pytest.raises(InputError):
        user.user_profile_setemail(user_2['token'], '*****@*****.**')
    clear()
Esempio n. 8
0
def route_user_profile_setemail():
    """Update the authorised user's email.

    Args:
        token (string): unique identifier of user.
        email (string): what the email will be set to.

    Returns:
        (dict): Contains no key types.
    """
    payload = request.get_json()
    try:
        return dumps(
            user.user_profile_setemail(payload['token'], payload['email']))
    except (InputError, AccessError) as e:
        return e
Esempio n. 9
0
def test_invalid_position(user_1):
    """Test for characters '\', '.' or '_' at the end or start of the personal info part.
    """
    with pytest.raises(InputError):
        user.user_profile_setemail(user_1['token'], '*****@*****.**')
    clear()
Esempio n. 10
0
def test_invalid_email_personal_info_special_2(user_1):
    """Test for invalid characters (including special characters other than '\', '.' or '_').
    """
    with pytest.raises(InputError):
        user.user_profile_setemail(user_1['token'], 'john_smi#^[email protected]')
    clear()
Esempio n. 11
0
def test_invalid_email_domain_period(user_1):
    """Test for no full stop in the domain.
    """
    with pytest.raises(InputError):
        user.user_profile_setemail(user_1['token'], 'test123@gmailcom')
    clear()
Esempio n. 12
0
def test_invalid_email_domain(user_1):
    """Test for no @ character and missing string in the domain.
    """
    with pytest.raises(InputError):
        user.user_profile_setemail(user_1['token'], 'test123.com')
    clear()
Esempio n. 13
0
def test_user_valid(user_1, logout_user_1):
    """Test for whether the user is logged in and authorised to set their email.
    """
    with pytest.raises(AccessError):
        user.user_profile_setemail(user_1['token'], '*****@*****.**')
    clear()