def test_create_vol_backed_img_snapshotting_policy_blocks_project(self):
        """Don't permit a snapshot of a volume backed instance if configured
        not to based on project
        """
        body = {
            'createImage': {
                'name': 'Snapshot 1',
            },
        }
        rule_name = "compute:snapshot_volume_backed"
        rules = {
                rule_name: "project_id:no_id",
                "compute:get": ""
        }
        policy.set_rules(oslo_policy.Rules.from_dict(rules))
        with mock.patch.object(compute_api.API, 'is_volume_backed_instance',
                               return_value=True):
            exc = self.assertRaises(exception.PolicyNotAuthorized,
                              self.controller._action_create_image,
                              self.req, FAKE_UUID, body=body)
            self.assertEqual(
                "Policy doesn't allow %s to be performed." % rule_name,
                exc.format_message())
dataset/ETHPy150Open openstack/nova/nova/tests/unit/api/openstack/compute/test_server_actions.py/ServerActionsControllerTestV2.test_create_vol_backed_img_snapshotting_policy_blocks_project/original