def test_has_perm_change_without_obj_without_any_permission(self):
        permission_logic = GroupInPermissionLogic('admin', any_permission=False)
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user2, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm2))
    def test_has_perm_delete_without_obj(self):
        permission_logic = GroupInPermissionLogic('admin')
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm3))
        self.assertFalse(permission_logic.has_perm(self.user2, self.perm3))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm3))
    def test_has_perm_change_with_obj(self):
        permission_logic = GroupInPermissionLogic("admin")
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm2, self.article))
        self.assertFalse(permission_logic.has_perm(self.user2, self.perm2, self.article))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm2, self.article))
    def test_has_perm_change_without_obj_with_two_groups(self):
        permission_logic = GroupInPermissionLogic(['admin', 'staff'])
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm2))
        self.assertTrue(permission_logic.has_perm(self.user2, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm2))
    def test_has_perm_delete_with_obj_with_two_groups(self):
        permission_logic = GroupInPermissionLogic(["admin", "staff"])
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm3, self.article))
        self.assertTrue(permission_logic.has_perm(self.user2, self.perm3, self.article))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm3, self.article))
    def test_has_perm_delete_without_obj(self):
        permission_logic = GroupInPermissionLogic('admin')
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm3))
        self.assertFalse(permission_logic.has_perm(self.user2, self.perm3))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm3))
    def test_has_perm_change_without_obj_without_any_permission(self):
        permission_logic = GroupInPermissionLogic('admin', any_permission=False)
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user2, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm2))
    def test_has_perm_change_without_obj_with_two_groups(self):
        permission_logic = GroupInPermissionLogic(['admin', 'staff'])
        add_permission_logic(self.article.__class__, permission_logic)

        self.assertTrue(permission_logic.has_perm(self.user1, self.perm2))
        self.assertTrue(permission_logic.has_perm(self.user2, self.perm2))
        self.assertFalse(permission_logic.has_perm(self.user3, self.perm2))
 def test_has_perm_delete_with_obj_with_anonymous(self):
     permission_logic = GroupInPermissionLogic('admin')
     add_permission_logic(self.article.__class__, permission_logic)
     self.assertFalse(
         permission_logic.has_perm(self.anonymous, self.perm3, self.article))
 def test_has_perm_change_with_obj_with_anonymous(self):
     permission_logic = GroupInPermissionLogic("admin")
     add_permission_logic(self.article.__class__, permission_logic)
     self.assertFalse(permission_logic.has_perm(self.anonymous, self.perm2, self.article))
 def test_has_perm_delete_with_obj_with_anonymous(self):
     permission_logic = GroupInPermissionLogic('admin')
     add_permission_logic(self.article.__class__, permission_logic)
     self.assertFalse(
         permission_logic.has_perm(self.anonymous, self.perm3, self.article))