From 2a6b74b558e762e4848dee0edc6d16ff016f9227 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Thu, 7 Nov 2019 12:29:06 +0100 Subject: [PATCH] Fix `snmp` unit test Under some condition, some code underneath `snmp` power driver seems to call `sleep` for its own reason. That fails sleep mock call assertion: AssertionError: Expected 'sleep' to be called once. Called 8 times. Calls: [call(0), call(0), call(0), ... call(0), call(5)]. This fix asserts just the sleep call we expect. Change-Id: I2edec4cbea2d39910f1fb52b0373169c03a4ec0d --- ironic/tests/unit/drivers/modules/test_snmp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ironic/tests/unit/drivers/modules/test_snmp.py b/ironic/tests/unit/drivers/modules/test_snmp.py index 1d0cd77e38..9702992d2a 100644 --- a/ironic/tests/unit/drivers/modules/test_snmp.py +++ b/ironic/tests/unit/drivers/modules/test_snmp.py @@ -1062,7 +1062,8 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase): calls = [mock.call(driver._snmp_oid())] * 2 mock_client.get.assert_has_calls(calls) self.assertEqual(states.POWER_ON, pstate) - mock_sleep.assert_called_once_with(5) + calls = [mock.call(5)] + mock_sleep.assert_has_calls(calls) def test_power_reset_on_snmp_get_failure(self, mock_get_client): # Ensure SNMP failure exceptions raised during a reset power on get