Fix mocking for TestGenericHardwareManager

This test class is testing the GenericHardwareManager, but did no
mocking for dispatch_to_managers. Therefore, if any of its methods
attempted to make a call to that method, it would break the unit tests.
This update adds mocking for get_managers to prevent the tests from
breaking if a method calls dispatch_to_managers.
Additionally, updates test_delete_configuration_skip_list.
test_delete_configuration_skip_list mocks get_skip_list_from_node.
mocks get_skip_list_from_node.
Correcting the return_value from a list to a set to match what is
returned from the original method.
Related-Bug: 2057668
Change-Id: Ifaa800449b49f64c6ba5779bfae1c8e2c3249903
This commit is contained in:
Daniel King
2024年03月19日 11:50:13 -04:00
parent 8de6e03539
commit cae6b15bbc

View File

@@ -127,6 +127,11 @@ class TestGenericHardwareManager(base.IronicAgentTest):
CONF.clear_override('disk_wait_attempts')
CONF.clear_override('disk_wait_delay')
self.mock_get_managers = mock.patch.object(
hardware, 'get_managers', autospec=True)
self.get_managers = self.mock_get_managers.start()
self.get_managers.return_value = [self.hardware]
def test_get_clean_steps(self):
expected_clean_steps = [
{
@@ -4712,7 +4717,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mocked_get_volume_name.side_effect = [
"/dev/md0", "small"
]
mocked_get_skip_list.return_value = ["small"]
mocked_get_skip_list.return_value = set({"small"})
self.hardware.delete_configuration(self.node, [])
Reference in New Issue
openstack/ironic-python-agent
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.