def _setup_session_user(self, *perms): user = User() # now permissions for perm in perms: user.add_perm(perm) return user
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
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'])
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')
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)
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
def test_lazy_dict_attrs(self): u = User() u.foobar = 1 assert u['foobar'] == 1
def test_defaults(self): u = User() self._check_empty(u)
def test_repr(self): u = User() assert repr(u)