def test_EditUserForm_validates_if_email_unchanged(self): email = '*****@*****.**' % factory.make_string() user = factory.make_User(email=email) form = EditUserForm(instance=user, data={ 'email': email, 'username': factory.make_string(), }) self.assertTrue(form.is_valid())
def test_EditUserForm_validates_if_email_unchanged(self): email = '*****@*****.**' % factory.getRandomString() user = factory.make_user(email=email) form = EditUserForm( instance=user, data={ 'email': email, 'username': factory.getRandomString(), }) self.assertTrue(form.is_valid())
def test_EditUserForm_validates_if_email_unchanged(self): email = "*****@*****.**" % factory.make_string() user = factory.make_User(email=email) form = EditUserForm( instance=user, data={ "email": email, "username": factory.make_string() }, ) self.assertTrue(form.is_valid())
def test_EditUserForm_fails_validation_if_email_taken(self): another_email = '*****@*****.**' % factory.make_string() factory.make_User(email=another_email) email = '*****@*****.**' % factory.make_string() user = factory.make_User(email=email) form = EditUserForm(instance=user, data={'email': another_email}) self.assertFormFailsValidationBecauseEmailNotUnique(form)
def get(self, request, *args, **kwargs): """Called by `TemplateView`: handle a GET request.""" self.object = user = self.get_object() profile_form = EditUserForm(instance=user, prefix='profile') password_form = AdminPasswordChangeForm(user=user, prefix='password') return self.respond(request, profile_form, password_form)