コード例 #1
0
def test_user_form_email_check_case_insensitive(admin_user, editor_user):
    form = UserCreationForm(data={
        'email': editor_user.email.upper(),
        'password1': '123',
        'password2': '123',
        'is_staff': True,
        'is_superuser': False,
        'state': 'active',
    })
    form.user = admin_user
    assert form.is_valid() is False
    assert 'email' in form.errors
コード例 #2
0
def test_user_form_email_is_saved_with_small_letters(admin_user):
    form = UserCreationForm(data={
        'email': '*****@*****.**',
        'password1': '123',
        'password2': '123',
        'fullname': 'R K',
        'is_staff': True,
        'is_superuser': False,
        'state': 'pending',
    })
    form.user = admin_user
    assert form.is_valid() is True
    user = form.save()
    assert user.email == "*****@*****.**"
コード例 #3
0
def test_user_form_validity(email, password1, password2, customfields,
                            fullname, is_staff, is_superuser, state, validity):
    form = UserCreationForm(
        data={
            'email': email,
            'password1': password1,
            'password2': password2,
            'customfields': customfields,
            'fullname': fullname,
            'is_staff': is_staff,
            'is_superuser': is_superuser,
            'state': state,
        })

    assert form.is_valid() is validity
コード例 #4
0
def test_user_form_validity(admin_user, email, password1, password2, fullname, is_staff, is_superuser, state,
                            validity):
    form = UserCreationForm(data={
        'email': email,
        'password1': password1,
        'password2': password2,
        'fullname': fullname,
        'is_staff': is_staff,
        'is_superuser': is_superuser,
        'state': state,
    })

    form.user = admin_user

    assert form.is_valid() is validity
コード例 #5
0
def test_user_form_add_organization(admin_user, valid_organization):
    form = UserCreationForm(data={
        'email': '*****@*****.**',
        'password1': '123',
        'password2': '123',
        'fullname': 'R K',
        'is_staff': True,
        'is_superuser': False,
        'state': 'pending',
        'organizations': [valid_organization]
    })
    form.user = admin_user
    assert form.is_valid() is True
    user = form.save()
    organization = Organization.objects.get(id=valid_organization.id)
    assert user in organization.users.all()
コード例 #6
0
def test_user_form_add_organization(valid_organization):
    form = UserCreationForm(
        data={
            'email': '*****@*****.**',
            'password1': '123',
            'password2': '123',
            'customfields': '{"official_phone": "", "official_position": ""}',
            'fullname': 'R K',
            'is_staff': True,
            'is_superuser': False,
            'state': 'pending',
            'organizations': [valid_organization]
        })
    assert form.is_valid() is True
    user = form.save()
    organization = Organization.objects.get(id=valid_organization.id)
    assert user in organization.users.all()
コード例 #7
0
def user_create_form_with_posted_data(posted_data):
    form = UserCreationForm(data=json.loads(posted_data))
    return form