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
This commit is contained in:
Ilya Etingof 2019-11-07 12:29:06 +01:00
parent acfc2ea440
commit 2a6b74b558
1 changed files with 2 additions and 1 deletions

View File

@ -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