Fix unit test exception KeyErrors
There are several places in the unit tests where exceptions are being used as side_effects without providing the kwargs they require for their messages. This adds the required kwargs. Closes-Bug: #1688366 Change-Id: Ie13e1b6fd4e75fce0a6b7225c4bd294889cf07c7
This commit is contained in:
parent
7f050fef50
commit
df91955cff
|
@ -378,7 +378,7 @@ class HostTestCaseV21(test.TestCase):
|
|||
s_ref = self._create_compute_service()
|
||||
with mock.patch.object(self.controller.api,
|
||||
'instance_get_all_by_host') as m:
|
||||
m.side_effect = exception.HostMappingNotFound
|
||||
m.side_effect = exception.HostMappingNotFound(name='something')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, self.req, s_ref['host'])
|
||||
|
||||
|
|
|
@ -639,7 +639,7 @@ class HypervisorsTestV21(test.NoDBTestCase):
|
|||
req = self._get_request(True)
|
||||
with mock.patch.object(self.controller.host_api,
|
||||
'instance_get_all_by_host') as m:
|
||||
m.side_effect = exception.HostMappingNotFound
|
||||
m.side_effect = exception.HostMappingNotFound(name='something')
|
||||
self.assertRaises(exc.HTTPNotFound,
|
||||
self.controller.servers, req, 'hyper')
|
||||
|
||||
|
|
|
@ -494,7 +494,7 @@ class ServicesTestV21(test.TestCase):
|
|||
body = {'host': 'invalid', 'binary': 'nova-compute'}
|
||||
with mock.patch.object(self.controller.host_api,
|
||||
'service_update') as m:
|
||||
m.side_effect = exception.HostMappingNotFound
|
||||
m.side_effect = exception.HostMappingNotFound(name='something')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update,
|
||||
self.req,
|
||||
|
|
|
@ -1302,7 +1302,7 @@ class ComputeVolumeTestCase(BaseTestCase):
|
|||
self.instance_object, 'fake_id', 'fake_id2', {})
|
||||
|
||||
@mock.patch.object(cinder.API, 'create',
|
||||
side_effect=exception.OverQuota())
|
||||
side_effect=exception.OverQuota(overs='something'))
|
||||
def test_prep_block_device_over_quota_failure(self, mock_create):
|
||||
instance = self._create_fake_instance_obj()
|
||||
bdms = [
|
||||
|
|
|
@ -4151,7 +4151,8 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
|||
|
||||
def test_build_and_run_volume_encryption_not_supported(self):
|
||||
self._test_build_and_run_spawn_exceptions(
|
||||
exception.VolumeEncryptionNotSupported(reason=""))
|
||||
exception.VolumeEncryptionNotSupported(volume_type='something',
|
||||
volume_id='something'))
|
||||
|
||||
def test_build_and_run_invalid_input(self):
|
||||
self._test_build_and_run_spawn_exceptions(
|
||||
|
|
|
@ -2442,7 +2442,7 @@ class ConductorTaskRPCAPITestCase(_BaseTaskTestCase,
|
|||
def test(self, context, instance):
|
||||
return mock.sentinel.iransofaraway
|
||||
|
||||
mock_im.side_effect = exc.InstanceMappingNotFound
|
||||
mock_im.side_effect = exc.InstanceMappingNotFound(uuid='something')
|
||||
ctxt = mock.MagicMock()
|
||||
inst = mock.MagicMock()
|
||||
self.assertEqual(mock.sentinel.iransofaraway,
|
||||
|
|
|
@ -5959,10 +5959,11 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
self.assertTrue(drvr.instance_exists(None))
|
||||
|
||||
mock_get_guest.side_effect = exception.InstanceNotFound
|
||||
mock_get_guest.side_effect = exception.InstanceNotFound(
|
||||
instance_id='something')
|
||||
self.assertFalse(drvr.instance_exists(None))
|
||||
|
||||
mock_get_guest.side_effect = exception.InternalError
|
||||
mock_get_guest.side_effect = exception.InternalError(err='something')
|
||||
self.assertFalse(drvr.instance_exists(None))
|
||||
|
||||
def test_estimate_instance_overhead_spawn(self):
|
||||
|
|
|
@ -120,7 +120,8 @@ class TestPowerVMDriver(test.NoDBTestCase):
|
|||
mock_del.reset_mock()
|
||||
|
||||
# InstanceNotFound exception, non-forced
|
||||
mock_pwroff.side_effect = exception.InstanceNotFound
|
||||
mock_pwroff.side_effect = exception.InstanceNotFound(
|
||||
instance_id='something')
|
||||
self.drv.destroy('context', self.inst, [], block_device_info={},
|
||||
destroy_disks=False)
|
||||
mock_pwroff.assert_called_once_with(
|
||||
|
|
Loading…
Reference in New Issue