From 35349246acb384e1080558c7f3fb04314e81f709 Mon Sep 17 00:00:00 2001 From: Julia Kreger <juliaashleykreger@gmail.com> Date: Fri, 14 Oct 2022 07:31:02 -0700 Subject: [PATCH] Fix snmp driver sleep call count Mocking time.sleep is known to be problematic in general, espescially when eventlet is involved. Since this can generate false failures, change the unit test to just check that it was called, as opposed to trying to count the number of times so we don't accidently count other test's calling time.sleep. Change-Id: I4323e74d7af008a651719fb972df667eb823e314 --- ironic/tests/unit/drivers/modules/test_snmp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ironic/tests/unit/drivers/modules/test_snmp.py b/ironic/tests/unit/drivers/modules/test_snmp.py index 00799dc4d2..5391d7ac59 100644 --- a/ironic/tests/unit/drivers/modules/test_snmp.py +++ b/ironic/tests/unit/drivers/modules/test_snmp.py @@ -761,7 +761,7 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase): driver = snmp._get_driver(self.node) mock_client.get.return_value = driver.value_power_on pstate = driver.power_on() - mock_sleep.assert_called_once_with(1) + self.assertTrue(mock_sleep.called) mock_client.set.assert_called_once_with(driver._snmp_oid(), driver.value_power_on) mock_client.get.assert_called_once_with(driver._snmp_oid()) @@ -775,7 +775,7 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase): driver = snmp._get_driver(self.node) mock_client.get.return_value = driver.value_power_off pstate = driver.power_off() - mock_sleep.assert_called_once_with(1) + self.assertTrue(mock_sleep.called) mock_client.set.assert_called_once_with(driver._snmp_oid(), driver.value_power_off) mock_client.get.assert_called_once_with(driver._snmp_oid())