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
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 == "*****@*****.**"
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
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
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()
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()
def user_create_form_with_posted_data(posted_data): form = UserCreationForm(data=json.loads(posted_data)) return form