Exemplo n.º 1
0
    def _setup_session_user(self, *perms):
        user = User()

        # now permissions
        for perm in perms:
            user.add_perm(perm)
        return user
Exemplo n.º 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
Exemplo n.º 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'])
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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'])
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 12
0
 def test_lazy_dict_attrs(self):
     u = User()
     u.foobar = 1
     assert u['foobar'] == 1
Exemplo n.º 13
0
 def test_defaults(self):
     u = User()
     self._check_empty(u)
Exemplo n.º 14
0
 def test_repr(self):
     u = User()
     assert repr(u)
Exemplo n.º 15
0
 def test_lazy_dict_attrs(self):
     u = User()
     u.foobar = 1
     assert u['foobar'] == 1