def test_basics(self): jane = self._make_user("*****@*****.**") john = self._make_user("*****@*****.**") roger = self._make_user("*****@*****.**") assert permissions.has_permission(jane, "can-frobulate") assert not permissions.has_permission(john, "can-frobulate") assert not permissions.has_permission(jane, "can-durlingate") assert permissions.has_permission(john, "can-durlingate") assert permissions.has_permission(jane, "can-tergonize") assert not permissions.has_permission(john, "can-tergonize") assert permissions.has_permission(roger, "can-tergonize")
def test_admin_check(self): user = users_factories.UserFactory.build(isAdmin=False, email="*****@*****.**") assert not permissions.has_permission(user, "can-frobulate")
def test_star(self): user = self._make_user("*****@*****.**") assert permissions.has_permission(user, "can-frobulate")
def test_empty_permission_list(self): user = self._make_user("*****@*****.**") assert not permissions.has_permission(user, "unknown-permission")
def can_add_or_modify(self): # We don't call `has_permission()` from `is_accessible()` # because we still want admin users to be able to list # reimbursement rules. We want to restrict addition and # modification only. return permissions.has_permission(current_user, "add-or-modify-custom-reimbursement-rules")