'Test volume can be extended at the manager level.'

@mock.patch('cinder.compute.API')
def _test_extend_volume_manager_successful(self, volume, nova_api):

    def fake_extend(volume, new_size):
        volume['size'] = new_size
    nova_extend_volume = nova_api.return_value.extend_volume
    fake_reservations = ['RESERVATION']
    orig_status = volume.status
    with mock.patch.object(self.volume.driver, 'extend_volume') as extend_volume:
        with mock.patch.object(QUOTAS, 'commit') as quotas_commit:
            extend_volume.return_value = fake_extend
            volume.status = 'extending'
            self.volume.extend_volume(self.context, volume, '4', fake_reservations)
            volume.refresh()
            self.assertEqual(4, volume.size)
            self.assertEqual(orig_status, volume.status)
            quotas_commit.assert_called_with(self.context, ['RESERVATION'], project_id=volume.project_id)
            if (orig_status == 'in-use'):
                instance_uuids = [attachment.instance_uuid for attachment in volume.volume_attachment]
                nova_extend_volume.assert_called_with(self.context, instance_uuids, volume.id)
