def test_has_perm_admin(self): """Test that an admin user can execute.""" user = Mock(spec=User, admin=True) req = Mock(user=user) accessPerm = ResourceTypeAccessPermission() result = accessPerm.has_permission(request=req, view=None) self.assertTrue(result)
def test_has_perm_with_no_access_on_get(self): """Test that a user read.""" user = Mock(spec=User, admin=False) req = Mock(user=user, method="GET") accessPerm = ResourceTypeAccessPermission() result = accessPerm.has_permission(request=req, view=None) self.assertFalse(result)
def test_has_perm_with_no_access_on_post(self): """Test that a user cannot execute POST.""" user = Mock(spec=User, admin=False) req = Mock(user=user, method="POST", META={"PATH_INFO": "http://localhost/api/v1/resource-types/"}) accessPerm = ResourceTypeAccessPermission() result = accessPerm.has_permission(request=req, view=None) self.assertFalse(result)