Skip to content

Commit 88b2206

Browse files
Fix wrong assertions in unit tests
Change-Id: I54dff4d5ed513690d0fae65de47a1a9c23aebbd4 Closes-Bug: #1840601 (cherry picked from commit 8ea5e37)
1 parent a8e19af commit 88b2206

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

nova/tests/unit/cmd/test_baseproxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_proxy(self, mock_start, mock_init, mock_gmr, mock_log,
6363
mock_exists):
6464
baseproxy.proxy('0.0.0.0', '6080')
6565
mock_log.assert_called_once_with(baseproxy.CONF, 'nova')
66-
mock_gmr.mock_assert_called_once_with(version)
66+
mock_gmr.assert_called_once_with(version, conf=baseproxy.CONF)
6767
mock_init.assert_called_once_with(
6868
listen_host='0.0.0.0', listen_port='6080', source_is_ipv6=False,
6969
cert='self.pem', key=None, ssl_only=False,

nova/tests/unit/virt/ironic/test_driver.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,9 +1919,10 @@ def test_power_off_soft_exception(self, mock_sp, fake_validate):
19191919
mock_sp.side_effect = [ironic_exception.BadRequest(), None]
19201920

19211921
self._test_power_off(timeout=30)
1922-
mock_sp.assert_has_calls([mock.call(node.uuid, 'off', soft=True,
1923-
timeout=30).
1924-
mock.call(node.uuid, 'off')])
1922+
expected_calls = [mock.call(node.uuid, 'off', soft=True, timeout=30),
1923+
mock.call(node.uuid, 'off')]
1924+
self.assertEqual(len(expected_calls), mock_sp.call_count)
1925+
mock_sp.assert_has_calls(expected_calls)
19251926

19261927
@mock.patch.object(ironic_driver.IronicDriver,
19271928
'_validate_instance_and_node')
@@ -1931,9 +1932,10 @@ def test_power_off_soft_not_stopped(self, mock_sp, fake_validate):
19311932
fake_validate.side_effect = [node, node]
19321933

19331934
self._test_power_off(timeout=30)
1934-
mock_sp.assert_has_calls([mock.call(node.uuid, 'off', soft=True,
1935-
timeout=30).
1936-
mock.call(node.uuid, 'off')])
1935+
expected_calls = [mock.call(node.uuid, 'off', soft=True, timeout=30),
1936+
mock.call(node.uuid, 'off')]
1937+
self.assertEqual(len(expected_calls), mock_sp.call_count)
1938+
mock_sp.assert_has_calls(expected_calls)
19371939

19381940
@mock.patch.object(FAKE_CLIENT.node, 'vif_attach')
19391941
def test_plug_vifs_with_port(self, mock_vatt):

nova/tests/unit/virt/vmwareapi/test_vmops.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,15 +2830,16 @@ def test_attach_interface(self, mock_get_vm_ref,
28302830
self._vmops.attach_interface(self._context, self._instance,
28312831
self._image_meta, self._network_values)
28322832
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
2833-
mock_get_attach_port_index(self._session, 'fake-ref')
2833+
mock_get_attach_port_index.assert_called_once_with(self._session,
2834+
'fake-ref')
28342835
mock_get_network_attach_config_spec.assert_called_once_with(
28352836
self._session.vim.client.factory, vif_info, 1,
28362837
extra_specs.vif_limits)
28372838
mock_reconfigure_vm.assert_called_once_with(self._session,
28382839
'fake-ref',
28392840
'fake-attach-spec')
2840-
_network_api.update_instance_vnic_index(mock.ANY,
2841-
self._instance, self._network_values, 1)
2841+
_network_api.update_instance_vnic_index.assert_called_once_with(
2842+
mock.ANY, self._instance, self._network_values, 1)
28422843

28432844
@mock.patch.object(vif, 'get_network_device', return_value='device')
28442845
@mock.patch.object(vm_util, 'reconfigure_vm')
@@ -2859,14 +2860,15 @@ def test_detach_interface(self, mock_get_vm_ref,
28592860
self._vmops.detach_interface(self._context, self._instance,
28602861
self._network_values)
28612862
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
2862-
mock_get_detach_port_index(self._session, 'fake-ref')
2863+
mock_get_detach_port_index.assert_called_once_with(self._session,
2864+
'fake-ref', None)
28632865
mock_get_network_detach_config_spec.assert_called_once_with(
28642866
self._session.vim.client.factory, 'device', 1)
28652867
mock_reconfigure_vm.assert_called_once_with(self._session,
28662868
'fake-ref',
28672869
'fake-detach-spec')
2868-
_network_api.update_instance_vnic_index(mock.ANY,
2869-
self._instance, self._network_values, None)
2870+
_network_api.update_instance_vnic_index.assert_called_once_with(
2871+
mock.ANY, self._instance, self._network_values, None)
28702872

28712873
@mock.patch.object(vm_util, 'get_vm_ref', return_value='fake-ref')
28722874
def test_get_mks_console(self, mock_get_vm_ref):
@@ -2937,12 +2939,13 @@ def test_attach_interface_with_limits(self, mock_get_vm_ref,
29372939
self._image_meta,
29382940
self._network_values)
29392941
mock_get_vm_ref.assert_called_once_with(self._session, self._instance)
2940-
mock_get_attach_port_index(self._session, 'fake-ref')
2942+
mock_get_attach_port_index.assert_called_once_with(self._session,
2943+
'fake-ref')
29412944
mock_get_network_attach_config_spec.assert_called_once_with(
29422945
self._session.vim.client.factory, vif_info, 1,
29432946
extra_specs.vif_limits)
29442947
mock_reconfigure_vm.assert_called_once_with(self._session,
29452948
'fake-ref',
29462949
'fake-attach-spec')
2947-
_network_api.update_instance_vnic_index(mock.ANY,
2948-
self._instance, self._network_values, 1)
2950+
_network_api.update_instance_vnic_index.assert_called_once_with(
2951+
mock.ANY, self._instance, self._network_values, 1)

0 commit comments

Comments
 (0)