'Create/Delete clones test.'

@mock.patch.object(requests, 'request', FakeRequests)
def test_create_destroy_clones(self):

    volume1 = {'name': 'test_volume_01', 'id': '01', 'size': 1}
    volume2 = {'name': 'test_volume_02', 'id': '02', 'size': 2}
    volume3 = {'name': 'test_volume_03', 'id': '03', 'size': 1}
    snapshot = {'name': 'snap_01', 'id': '01', 'volume_name': volume1['name'], 'volume_size': 1}
    self.driver.create_volume(volume1)
    self.driver.create_snapshot(snapshot)
    self.assertRaises(exception.VolumeNotFound, self.driver.create_volume_from_snapshot, volume2, {'name': snapshot['name'], 'id': snapshot['id'], 'volume_name': 'wrong_vol'})
    self.assertRaises(exception.SnapshotNotFound, self.driver.create_volume_from_snapshot, volume2, {'name': 'wrong_snap', 'id': 'wrong_id', 'volume_name': snapshot['volume_name']})
    self.assertRaises(exception.VolumeNotFound, self.driver.create_cloned_volume, volume3, volume2)
    self.driver.create_volume_from_snapshot(volume2, snapshot)
    self.driver.create_cloned_volume(volume3, volume1)
    self.driver.delete_volume(volume3)
    self.driver.delete_volume(volume2)
    self.driver.delete_snapshot(snapshot)
    self.driver.delete_volume(volume1)
