def test_form_UserCreationCustomForm_raises_error_if_email_has_accentuation(self): fields = { "email": "pedro.alcâ[email protected]", "password1": "1", "password2": "1", "fullname": "Pedro Alcântara", } form = UserCreationCustomForm(data=fields) self.assertFalse(form.is_valid())
def create_account_post(request): form = UserCreationCustomForm(request.POST) if not form.is_valid(): context = RequestContext(request, {'form': form, }) return render_to_response('myAuth/create_account.html', context) user = form.save() context = Context({'account': user}) template = get_template('myAuth/confirm_account_email.html') template = template.render(context) send_confirmation_email(template, "[email protected],br", [user.email]) return HttpResponseRedirect(reverse('myAuth:create_account_success', args=[user.pk]))
def test_form_UserCreationCustomForm_raises_error_if_email_has_not_full_domain(self): fields = {"email": "pedro@com", "password1": "1", "password2": "1", "fullname": "Pedro Alcântara"} form = UserCreationCustomForm(data=fields) self.assertFalse(form.is_valid())
def test_form_UserCreationCustomForm_raises_error_if_fullname_has_only_one_part_of_the_name(self): fields = {"email": "*****@*****.**", "password1": "1", "password2": "1", "fullname": "João "} form = UserCreationCustomForm(data=fields) self.assertFalse(form.is_valid(), form.errors)
def test_form_UserCreationCustomForm_raises_error_if_fullname_is_empty(self): fields = {"email": "*****@*****.**", "password1": "1", "password2": "1", "fullname": ""} form = UserCreationCustomForm(data=fields) self.assertFalse(form.is_valid())
def test_form_UserCreationCustomForm_raises_error_if_passwords_does_not_match(self): fields = {"fullname": "John Doe", "email": "*****@*****.**", "password1": "1", "password2": "2"} form = UserCreationCustomForm(fields) self.assertFalse(form.is_valid())