'Tests the case where driver.extend_volume raises
NotImplementedError.'

def test_extend_volume_not_implemented_error(self):

    inst_obj = objects.Instance(id=3, uuid=uuids.instance)
    connection_info = {'foo': 'bar'}
    bdm = objects.BlockDeviceMapping(source_type='volume', destination_type='volume', volume_id=uuids.volume_id, volume_size=10, instance_uuid=uuids.instance, device_name='/dev/vda', connection_info=jsonutils.dumps(connection_info))
    @mock.patch.object(self.compute, 'volume_api')
    @mock.patch.object(objects.BlockDeviceMapping, 'get_by_volume_and_instance')
    @mock.patch.object(objects.BlockDeviceMapping, 'save')
    @mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
    def do_test(add_fault_mock, bdm_save, bdm_get_by_vol_and_inst, volume_api):
        bdm_get_by_vol_and_inst.return_value = bdm
        volume_api.get.return_value = {'size': 20}
        self.assertRaises(exception.ExtendVolumeNotSupported, self.compute.extend_volume, self.context, inst_obj, uuids.volume_id)
        add_fault_mock.assert_called_once_with(self.context, inst_obj, mock.ANY, mock.ANY)
    with mock.patch.dict(self.compute.driver.capabilities, supports_extend_volume=False):
        do_test()
