Fix wrong assertion methods

Replcae 'has_calls' with 'assert_has_calls' or
remove 'has_calls'.

Change-Id: I65f9a761af75d94052362056fe1c9ba152f6449e
Closes-Bug: 1989280
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
Takashi Natsume 2022-09-12 20:01:09 +09:00
parent 04991fce4b
commit a4effc7e54
5 changed files with 17 additions and 18 deletions

View File

@ -114,7 +114,8 @@ class MigrationUtilsTestCase(test_base.OsWinBaseTestCase):
mock.sentinel.job_path_ValidatePlannedSystem),
mock.call(mock.sentinel.ret_val_RealizePlannedSystem,
mock.sentinel.job_path_RealizePlannedSystem)]
self._migrationutils._jobutils.check_ret_val.has_calls(expected_call)
self._migrationutils._jobutils.check_ret_val.assert_has_calls(
expected_call)
@ddt.data([mock.sentinel.planned_vm], [])
def test_get_planned_vm(self, planned_vm):

View File

@ -212,13 +212,13 @@ class VMUtils10TestCase(test_base.OsWinBaseTestCase):
sec_profile_serialization)
expected_call = [
mock.call(mock.sentinel.job_path_SetKeyProtector,
mock.sentinel.ret_val_SetKeyProtector),
mock.call(mock.sentinel.job_path_SetSecurityPolicy,
mock.sentinel.ret_val_SetSecurityPolicy),
mock.call(mock.sentinel.job_path_ModifySecuritySettings,
mock.sentinel.ret_val_ModifySecuritySettings)]
self._vmutils._jobutils.check_ret_val.has_calls(expected_call)
mock.call(mock.sentinel.ret_val_SetKeyProtector,
mock.sentinel.job_path_SetKeyProtector),
mock.call(mock.sentinel.ret_val_SetSecurityPolicy,
mock.sentinel.job_path_SetSecurityPolicy),
mock.call(mock.sentinel.ret_val_ModifySecuritySettings,
mock.sentinel.job_path_ModifySecuritySettings)]
self._vmutils._jobutils.check_ret_val.assert_has_calls(expected_call)
self.assertTrue(security_profile.EncryptStateAndVmMigrationTraffic)
self.assertTrue(security_profile.TpmEnabled)
self.assertTrue(security_profile.ShieldingRequested)

View File

@ -90,8 +90,8 @@ class HostUtils10TestCase(test_base.OsWinBaseTestCase):
'dev_id': mock_pci_dev.DeviceID}
self.assertEqual([expected_pci_dev], pci_devices)
self._hostutils._conn.Msvm_PciExpress.assert_called_once_with()
mock_get_pci_device_address.has_calls(
[mock.call(mock_pci_dev.DeviceInstancePath)] * 3)
mock_get_pci_device_address.assert_has_calls(
[mock.call(mock_pci_dev.DeviceInstancePath)] * 2)
def _check_get_pci_device_address_None(self, return_code=0):
pnp_device = mock.MagicMock()

View File

@ -252,8 +252,11 @@ class JobUtilsTestCase(test_base.OsWinBaseTestCase):
mock_calls = [
mock.call(ResourceSettings=[mock.sentinel.res_data])] * num_calls
mock_svc.ModifyResourceSettings.has_calls(mock_calls)
mock_sleep.has_calls(mock.call(1) * num_calls)
mock_svc.ModifyResourceSettings.assert_has_calls(mock_calls)
if num_calls > 1:
mock_sleep.assert_has_calls([mock.call(1)] * (num_calls - 1))
else:
mock_sleep.assert_not_called()
def test_add_virt_resource(self):
self._test_virt_method('AddResourceSettings', 3, 'add_virt_resource',

View File

@ -254,13 +254,8 @@ class PathUtilsTestCase(test_base.OsWinBaseTestCase):
mock_delete.assert_called_once_with(mock.sentinel.temporary_file)
@mock.patch.object(shutil, 'copytree')
@mock.patch('os.path.abspath')
def test_copy_dir(self, mock_abspath, mock_copytree):
mock_abspath.side_effect = [mock.sentinel.src, mock.sentinel.dest]
def test_copy_dir(self, mock_copytree):
self._pathutils.copy_dir(mock.sentinel.src, mock.sentinel.dest)
mock_abspath.has_calls(
[mock.call(mock.sentinel.src), mock.call(mock.sentinel.dest)])
mock_copytree.assert_called_once_with(mock.sentinel.src,
mock.sentinel.dest)