Beispiel #1
0
    def test_if_firstname_and_lastname_were_splitted_correctly(self):
        fields = {"fullname": "Pedro Oliveira Rocha", "email": "*****@*****.**", "password1": "1", "password2": "1"}

        form = UserCreationCustomForm(data=fields)
        form.full_clean()

        self.assertEquals(form.cleaned_data.get("first_name"), "Pedro")
        self.assertEquals(form.cleaned_data.get("last_name"), "Oliveira Rocha")
Beispiel #2
0
    def test_new_user_is_created_as_inactive(self):
        fields = {"email": "*****@*****.**", "password1": "1", "password2": "1", "fullname": "Ivens Teste"}

        form = UserCreationCustomForm(data=fields)
        form.save()

        user = User.objects.get(email=fields["email"])
        self.assertFalse(user.is_active)
Beispiel #3
0
    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())
Beispiel #4
0
    def test_form_UserCreationCustomForm_if_username_is_generated_properly(self):
        fields = {"fullname": "John Doe", "email": "*****@*****.**", "password1": "1", "password2": "1"}

        form = UserCreationCustomForm(data=fields)
        form.full_clean()
        from utils.generate_username import generate_username

        username = generate_username(fields["email"])

        self.assertEqual(username, form.cleaned_data.get("username"))
Beispiel #5
0
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]))
Beispiel #6
0
    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())
Beispiel #7
0
    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)
Beispiel #8
0
    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())
Beispiel #9
0
 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())