'Test begin_detaching and roll_detaching functions.'

def test_begin_roll_detaching_volume(self):

    instance_uuid = '12345678-1234-5678-1234-567812345678'
    volume = tests_utils.create_volume(self.context, **self.volume_params)
    attachment = db.volume_attach(self.context, {'volume_id': volume['id'], 'attached_host': 'fake-host'})
    db.volume_attached(self.context, attachment['id'], instance_uuid, 'fake-host', 'vdb')
    volume_api = cinder.volume.api.API()
    volume_api.begin_detaching(self.context, volume)
    volume = volume_api.get(self.context, volume['id'])
    self.assertEqual('detaching', volume['status'])
    volume_api.roll_detaching(self.context, volume)
    volume = volume_api.get(self.context, volume['id'])
    self.assertEqual('in-use', volume['status'])
