Fix wrong assertions in unit tests

Change-Id: I54dff4d5ed513690d0fae65de47a1a9c23aebbd4
Closes-Bug: #1840601
This commit is contained in:
Takashi NATSUME 2019-08-19 10:13:56 +09:00
parent ad482e53fb
commit 8ea5e37338
3 changed files with 21 additions and 16 deletions

View File

@ -63,7 +63,7 @@ class BaseProxyTestCase(test.NoDBTestCase):
mock_exists):
baseproxy.proxy('0.0.0.0', '6080')
mock_log.assert_called_once_with(baseproxy.CONF, 'nova')
mock_gmr.mock_assert_called_once_with(version)
mock_gmr.assert_called_once_with(version, conf=baseproxy.CONF)
mock_init.assert_called_once_with(
listen_host='0.0.0.0', listen_port='6080', source_is_ipv6=False,
cert='self.pem', key=None, ssl_only=False,

View File

@ -1934,9 +1934,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
mock_sp.side_effect = [ironic_exception.BadRequest(), None]
self._test_power_off(timeout=30)
mock_sp.assert_has_calls([mock.call(node.uuid, 'off', soft=True,
timeout=30).
mock.call(node.uuid, 'off')])
expected_calls = [mock.call(node.uuid, 'off', soft=True, timeout=30),
mock.call(node.uuid, 'off')]
self.assertEqual(len(expected_calls), mock_sp.call_count)
mock_sp.assert_has_calls(expected_calls)
@mock.patch.object(ironic_driver.IronicDriver,
'_validate_instance_and_node')
@ -1946,9 +1947,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
fake_validate.side_effect = [node, node]
self._test_power_off(timeout=30)
mock_sp.assert_has_calls([mock.call(node.uuid, 'off', soft=True,
timeout=30).
mock.call(node.uuid, 'off')])
expected_calls = [mock.call(node.uuid, 'off', soft=True, timeout=30),
mock.call(node.uuid, 'off')]
self.assertEqual(len(expected_calls), mock_sp.call_count)
mock_sp.assert_has_calls(expected_calls)
@mock.patch.object(FAKE_CLIENT.node, 'vif_attach')
def test_plug_vifs_with_port(self, mock_vatt):

View File

@ -2830,15 +2830,16 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
self._vmops.attach_interface(self._context, self._instance,
self._image_meta, self._network_values)
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
mock_get_attach_port_index(self._session, 'fake-ref')
mock_get_attach_port_index.assert_called_once_with(self._session,
'fake-ref')
mock_get_network_attach_config_spec.assert_called_once_with(
self._session.vim.client.factory, vif_info, 1,
extra_specs.vif_limits)
mock_reconfigure_vm.assert_called_once_with(self._session,
'fake-ref',
'fake-attach-spec')
_network_api.update_instance_vnic_index(mock.ANY,
self._instance, self._network_values, 1)
_network_api.update_instance_vnic_index.assert_called_once_with(
mock.ANY, self._instance, self._network_values, 1)
@mock.patch.object(vif, 'get_network_device', return_value='device')
@mock.patch.object(vm_util, 'reconfigure_vm')
@ -2859,14 +2860,15 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
self._vmops.detach_interface(self._context, self._instance,
self._network_values)
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
mock_get_detach_port_index(self._session, 'fake-ref')
mock_get_detach_port_index.assert_called_once_with(self._session,
'fake-ref', None)
mock_get_network_detach_config_spec.assert_called_once_with(
self._session.vim.client.factory, 'device', 1)
mock_reconfigure_vm.assert_called_once_with(self._session,
'fake-ref',
'fake-detach-spec')
_network_api.update_instance_vnic_index(mock.ANY,
self._instance, self._network_values, None)
_network_api.update_instance_vnic_index.assert_called_once_with(
mock.ANY, self._instance, self._network_values, None)
@mock.patch.object(vm_util, 'get_vm_ref', return_value='fake-ref')
def test_get_mks_console(self, mock_get_vm_ref):
@ -2937,12 +2939,13 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
self._image_meta,
self._network_values)
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
mock_get_attach_port_index(self._session, 'fake-ref')
mock_get_attach_port_index.assert_called_once_with(self._session,
'fake-ref')
mock_get_network_attach_config_spec.assert_called_once_with(
self._session.vim.client.factory, vif_info, 1,
extra_specs.vif_limits)
mock_reconfigure_vm.assert_called_once_with(self._session,
'fake-ref',
'fake-attach-spec')
_network_api.update_instance_vnic_index(mock.ANY,
self._instance, self._network_values, 1)
_network_api.update_instance_vnic_index.assert_called_once_with(
mock.ANY, self._instance, self._network_values, 1)