Exemplo n.º 1
0
    def test_register_user_form_should_not_work_with_empty_username(self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "",
            'password1': "mynameishelloworld123",
            'password2': "mynameishelloworld123"
        })

        self.assertFalse(form.is_valid(),
                         "ERROR! Register Form working with empty username?")
Exemplo n.º 2
0
    def test_register_user_form_should_not_work_with_weak_password(self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "******",
            'password1': "he",  # weak passwords
            'password2': "he"
        })

        self.assertFalse(form.is_valid(),
                         "ERROR! Register Form working with weak passwords")
Exemplo n.º 3
0
    def test_register_user_form_is_valid(self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "******",
            'password1': "mynameishelloworld123",
            'password2': "mynameishelloworld123"
        })

        self.assertTrue(
            form.is_valid(),
            "ERROR! Supposedly valid user creation form is invalid?")
Exemplo n.º 4
0
    def test_register_user_form_should_not_work_with_username_duplicates(self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "******",  # this username already exists in the db
            'password1': "mynameishelloworld123",
            'password2': "mynameishelloworld123"
        })

        self.assertFalse(
            form.is_valid(),
            "ERROR! Register Form working with duplicate usernames?")
Exemplo n.º 5
0
    def test_register_user_form_should_not_work_with_not_matching_passwords(
            self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "******",
            'password1': "mynameishelloworld123",  # non matching passwords
            'password2': "notmachingpasswords"
        })

        self.assertFalse(
            form.is_valid(),
            "ERROR! Register Form working with non matching passwords?")
Exemplo n.º 6
0
    def test_register_user_form_saves_in_database(self):
        form = forms.RegisterForm({
            'first_name': "Hello",
            'last_name': "World",
            'username': "******",
            'password1': "mynameishelloworld123",
            'password2': "mynameishelloworld123"
        })

        user = form.save()

        self.assertTrue(User.objects.get(username="******"),
                        "ERROR! Form save did not "
                        "reflect in the db")