'Good pass on managing an LVM volume.
This test case ensures that, when a logical volume with the
specified name exists, and the size is as expected, no error is
returned from driver.manage_existing, and that the rename_volume
function is called in the Brick LVM code with the correct arguments.'

def test_lvm_manage_existing(self):

    self._setup_stubs_for_manage_existing()
    ref = {'source-name': 'fake_lv'}
    vol = {'name': 'test', 'id': fake.VOLUME_ID, 'size': 0}
    def _rename_volume(old_name, new_name):
        self.assertEqual(ref['source-name'], old_name)
        self.assertEqual(vol['name'], new_name)
    with mock.patch.object(self.volume.driver.vg, 'rename_volume') as mock_rename_volume:
        with mock.patch.object(self.volume.driver.vg, 'get_volume', self._get_manage_existing_lvs):
            mock_rename_volume.return_value = _rename_volume
            size = self.volume.driver.manage_existing_get_size(vol, ref)
            self.assertEqual(2, size)
            model_update = self.volume.driver.manage_existing(vol, ref)
            self.assertIsNone(model_update)
