Beispiel #1
0
def test_get_or_create_user_no_username(mocker):
    gum = mocker.patch('magiclink.helpers.get_user_model')
    gum.return_value = CustomUserEmailOnly

    from magiclink.helpers import get_or_create_user
    email = '*****@*****.**'
    usr = get_or_create_user(email=email)
    assert usr.email == email
Beispiel #2
0
def test_get_or_create_user_exists_ignore_case(settings, user):  # NOQA: F811
    settings.MAGICLINK_EMAIL_IGNORE_CASE = True
    from magiclink import settings
    reload(settings)

    usr = get_or_create_user(email=user.email.upper())
    assert usr == user
    assert User.objects.count() == 1
Beispiel #3
0
def test_get_or_create_user_random_username(settings):
    settings.MAGICLINK_EMAIL_AS_USERNAME = False
    from magiclink import settings
    reload(settings)

    email = '*****@*****.**'
    usr = get_or_create_user(email=email)
    assert usr.email == email
    assert usr.username != email
    assert len(usr.username) == 10
Beispiel #4
0
def test_get_or_create_user_name(mocker):
    gum = mocker.patch('magiclink.helpers.get_user_model')
    gum.return_value = CustomUserName

    from magiclink.helpers import get_or_create_user
    email = '*****@*****.**'
    first = 'fname'
    last = 'lname'
    usr = get_or_create_user(email=email, first_name=first, last_name=last)
    assert usr.email == email
    assert usr.name == f'{first} {last}'
Beispiel #5
0
def test_get_or_create_user_last_name():
    last_name = 'lname'
    usr = get_or_create_user(email='*****@*****.**', last_name=last_name)
    assert usr.last_name == last_name
Beispiel #6
0
def test_get_or_create_user_first_name():
    first_name = 'fname'
    usr = get_or_create_user(email='*****@*****.**', first_name=first_name)
    assert usr.first_name == first_name
Beispiel #7
0
def test_get_or_create_user_email_as_username():
    email = '*****@*****.**'
    usr = get_or_create_user(email=email)
    assert usr.email == email
    assert usr.username == email
Beispiel #8
0
def test_get_or_create_user_exists(user):  # NOQA: F811
    usr = get_or_create_user(email=user.email)
    assert usr == user
    assert User.objects.count() == 1
Beispiel #9
0
def user():
    user = get_or_create_user(email='*****@*****.**')
    return user