Пример #1
0
    def test_get_user_returns_none_if_auth_failed(self):

        form = EntreeAuthForm(data=dict(username=self.username,
                                        password='******' % self.password))
        form.is_valid()

        assert_equals(None, form.get_user())
Пример #2
0
    def test_auth_form_clean(self):
        data = {'username': self.username, 'password': self.password}
        form = EntreeAuthForm(data=data)

        assert_equals(True, form.is_valid())
        assert_equals(self.username, str(form.cleaned_data['username']))
        assert_equals(self.password, str(form.cleaned_data['password']))
Пример #3
0
    def test_get_user_returns_user(self):

        form = EntreeAuthForm(
            data=dict(username=self.username, password=self.password))
        form.is_valid()

        assert_equals(self.user, form.get_user())
Пример #4
0
    def test_auth_form_clean(self):
        data = {'username': self.username, 'password': self.password}
        form = EntreeAuthForm(data=data)

        assert_equals(True, form.is_valid())
        assert_equals(self.username, str(form.cleaned_data['username']))
        assert_equals(self.password, str(form.cleaned_data['password']))
Пример #5
0
    def test_auth_form_bad_password(self):
        data = {'username': self.username, 'password': '******' % self.password}

        form = EntreeAuthForm(data=data)
        form.is_valid()

        #TODO - better assert
        assert_equals(['__all__'], form.errors.keys())
Пример #6
0
    def test_auth_form_bad_password(self):
        data = {
            'username': self.username,
            'password': '******' % self.password
        }

        form = EntreeAuthForm(data=data)
        form.is_valid()

        #TODO - better assert
        assert_equals(['__all__'], form.errors.keys())
Пример #7
0
    def test_missing_session_middleware_raises(self):
        mck = Mock()
        mck.return_value = False

        request = HttpRequest()
        request.session = Mock()
        request.session.test_cookie_worked = lambda: False

        form = EntreeAuthForm(request=request, data=dict(username=self.username, password=self.password))
        form.is_valid()

        #TODO - better assert
        assert_equals(['__all__'], form.errors.keys())
Пример #8
0
    def test_missing_session_middleware_raises(self):
        mck = Mock()
        mck.return_value = False

        request = HttpRequest()
        request.session = Mock()
        request.session.test_cookie_worked = lambda: False

        form = EntreeAuthForm(request=request,
                              data=dict(username=self.username,
                                        password=self.password))
        form.is_valid()

        #TODO - better assert
        assert_equals(['__all__'], form.errors.keys())
Пример #9
0
    def test_get_user_returns_none_if_auth_failed(self):

        form = EntreeAuthForm(data=dict(username=self.username, password='******' % self.password))
        form.is_valid()

        assert_equals(None, form.get_user())
Пример #10
0
    def test_get_user_returns_user(self):

        form = EntreeAuthForm(data=dict(username=self.username, password=self.password))
        form.is_valid()

        assert_equals(self.user, form.get_user())