'Test force parameter on _detach_volume.
On the driver if we receive the force parameter we will do everything
even with Exceptions on disconnect, terminate, and remove export.'

@mock.patch('cinder.volume.driver.brick_exception')
@mock.patch('cinder.tests.fake_driver.FakeLoggingVolumeDriver.terminate_connection', side_effect=Exception)
@mock.patch('cinder.tests.fake_driver.FakeLoggingVolumeDriver.remove_export', side_effect=Exception)
def test_detach_volume_force(self, remove_mock, terminate_mock, exc_mock):

    connector = mock.Mock()
    connector.disconnect_volume.side_effect = Exception
    exc = exc_mock.ExceptionChainer.return_value
    exc.context.return_value.__enter__.return_value = exc
    exc.context.return_value.__exit__.return_value = True
    volume = {'id': fake.VOLUME_ID}
    attach_info = {'device': {}, 'connector': connector, 'conn': {'data': {}}}
    self.assertRaises(TypeError, self.volume.driver._detach_volume, self.context, attach_info, volume, {}, force=True)
    self.assertTrue(connector.disconnect_volume.called)
    self.assertTrue(remove_mock.called)
    self.assertTrue(terminate_mock.called)
    self.assertEqual(3, exc.context.call_count)
