Fix mock use for mock 1.1.0

Correct the way we check the calls by using the proper mock method. Add
a new test to expand coverage of the area being fixed.

Change-Id: I344ee52dd0ea77bc45b6d3e2713ae1ba8b225ffc
This commit is contained in:
Doug Hellmann 2015-07-10 12:22:26 +00:00
parent a5e707c2bc
commit c7b31385ac

View File

@ -84,4 +84,16 @@ class TimerTestCase(test_utils.BaseTestCase):
callback = mock.Mock() callback = mock.Mock()
remaining = t.check_return(callback) remaining = t.check_return(callback)
self.assertEqual(0, remaining) self.assertEqual(0, remaining)
callback.assert_called_once callback.assert_called_once_with()
@mock.patch('oslo_utils.timeutils.now')
def test_duration_callback_with_args(self, now):
now.return_value = 0
t = common.DecayingTimer(2)
t.start()
now.return_value = 3
callback = mock.Mock()
remaining = t.check_return(callback, 1, a='b')
self.assertEqual(0, remaining)
callback.assert_called_once_with(1, a='b')