Пример #1
0
    def _setup_session_user(self, *perms):
        user = User()

        # now permissions
        for perm in perms:
            user.add_perm(perm)
        return user
Пример #2
0
    def test_get_set_properties(self):
        u = User()
        assert not u.is_authenticated
        u.is_authenticated = True
        assert u.is_authenticated

        u = User()
        assert not u.is_super_user
        u.is_super_user = True
        assert u.is_super_user
Пример #3
0
    def test_perms(self):
        u = User()
        assert not u.has_perm('foobar')
        u.add_perm('foobar')
        assert u.has_perm('foobar')

        assert not u.has_any_perm('baz', 'zip')
        assert not u.has_any_perm(('baz', 'zip'))
        assert u.has_any_perm('baz', 'foobar')
        assert u.has_any_perm('foobar', 'baz')
        assert u.has_any_perm(('baz', 'foobar'))
        assert u.has_any_perm(['foobar', 'baz'])
Пример #4
0
    def test_super_user_perms(self):
        u = User()
        u.is_super_user = True
        assert u.is_super_user
        assert u.has_perm('foobar')
        u.add_perm('foobar')
        assert u.has_perm('foobar')

        assert u.has_any_perm('baz', 'zip')
        assert u.has_any_perm('foobar', 'baz')
Пример #5
0
 def test_clear(self):
     u = User()
     u.is_authenticated = True
     u.is_super_user = True
     u.add_perm('foobar')
     u.clear()
     self._check_empty(u)
Пример #6
0
    def test_api_attrs_not_in_dict(self):
        u = User()
        u.foobar = 1

        assert u._is_authenticated is False
        assert '_is_authenticated' not in u

        assert u._is_super_user is False
        assert '_is_super_user' not in u

        assert not u.perms
        assert 'perms' not in u

        assert not u._messages
        assert '_messages' not in u
Пример #7
0
    def test_api_attrs_not_in_dict(self):
        u = User()
        u.foobar = 1

        assert u._is_authenticated is False
        assert '_is_authenticated' not in u

        assert u._is_super_user is False
        assert '_is_super_user' not in u

        assert not u.perms
        assert 'perms' not in u

        assert not u._messages
        assert '_messages' not in u
Пример #8
0
    def test_perms(self):
        u = User()
        assert not u.has_perm('foobar')
        u.add_perm('foobar')
        assert u.has_perm('foobar')

        assert not u.has_any_perm('baz', 'zip')
        assert not u.has_any_perm(('baz', 'zip'))
        assert u.has_any_perm('baz', 'foobar')
        assert u.has_any_perm('foobar', 'baz')
        assert u.has_any_perm(('baz', 'foobar'))
        assert u.has_any_perm(['foobar', 'baz'])
Пример #9
0
    def test_super_user_perms(self):
        u = User()
        u.is_super_user = True
        assert u.is_super_user
        assert u.has_perm('foobar')
        u.add_perm('foobar')
        assert u.has_perm('foobar')

        assert u.has_any_perm('baz', 'zip')
        assert u.has_any_perm('foobar', 'baz')
Пример #10
0
 def test_clear(self):
     u = User()
     u.is_authenticated = True
     u.is_super_user = True
     u.add_perm('foobar')
     u.clear()
     self._check_empty(u)
Пример #11
0
    def test_get_set_properties(self):
        u = User()
        assert not u.is_authenticated
        u.is_authenticated = True
        assert u.is_authenticated

        u = User()
        assert not u.is_super_user
        u.is_super_user = True
        assert u.is_super_user
Пример #12
0
 def test_lazy_dict_attrs(self):
     u = User()
     u.foobar = 1
     assert u['foobar'] == 1
Пример #13
0
 def test_defaults(self):
     u = User()
     self._check_empty(u)
Пример #14
0
 def test_repr(self):
     u = User()
     assert repr(u)
Пример #15
0
 def test_lazy_dict_attrs(self):
     u = User()
     u.foobar = 1
     assert u['foobar'] == 1