Fixed wrong assertion in test_vmops.py

There is wrong assert method in
nova.tests.virt.vmwareapi.vmwareapi.test_vmops.py:640
while checking a number of calls mocked method 'mkdir'.

We should use assertEqual(3, len(mock_mkdir.mock_calls))
instead of self.assertTrue(3, len(mock_mkdir.mock_calls))

But number of calling method 'mkdir' not always is 3.
If dict block_device_info contains key 'block_device_mapping'
with any information, method 'mkdir' wouldn't be called in method
self._vmops.spawn(). That is why corresponding check been added.

Change-Id: Ifc26e112b9c2974e0fb7a91ba39d5b2d887bd549
Closes-Bug: #1335859
This commit is contained in:
Sergey Nikitin 2014-06-30 17:55:46 +04:00
parent 4e35f5f2ee
commit aaa9d6a8a2
1 changed files with 11 additions and 1 deletions

View File

@ -637,7 +637,17 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
power_on=power_on)
mock_is_neutron.assert_called_once_with()
self.assertTrue(3, len(mock_mkdir.mock_calls))
expected_mkdir_calls = 3
if block_device_info and len(block_device_info.get(
'block_device_mapping', [])) > 0:
# if block_device_info contains key 'block_device_mapping'
# with any information, method mkdir wouldn't be called in
# method self._vmops.spawn()
expected_mkdir_calls = 0
self.assertEqual(expected_mkdir_calls, len(mock_mkdir.mock_calls))
mock_get_vnc_port.assert_called_once_with(self._session)
mock_get_mo_id_for_instance.assert_called_once_with(self._instance)
mock_get_res_pool_ref.assert_called_once_with(