From 902a66e53d29101a23c541c8b1090a33b8d89fb0 Mon Sep 17 00:00:00 2001 From: zhangyangyang Date: Fri, 15 Sep 2017 11:25:18 +0800 Subject: [PATCH] Removes use of timeutils.set_time_override The set_time_override function in timeutils was written as a helper function to mock utcnow for unittests before 'mock' was generally used. Now that we have mock and fixture, we no longer need to use it. Change-Id: Ibbdae2ba60f3d706eba59d8af13cf7ee9acfae23 Closes-Bug:#1266962 --- manila/tests/message/test_api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manila/tests/message/test_api.py b/manila/tests/message/test_api.py index a75c3aafe5..08a0874c6a 100644 --- a/manila/tests/message/test_api.py +++ b/manila/tests/message/test_api.py @@ -33,11 +33,12 @@ class MessageApiTest(test.TestCase): self.ctxt = context.RequestContext('admin', 'fakeproject', True) self.ctxt.request_id = 'fakerequestid' - def test_create(self): + @mock.patch.object(timeutils, 'utcnow') + def test_create(self, mock_utcnow): CONF.set_override('message_ttl', 300) - timeutils.set_time_override() - self.addCleanup(timeutils.clear_time_override) - expected_expires_at = timeutils.utcnow() + datetime.timedelta( + now = datetime.datetime.utcnow() + mock_utcnow.return_value = now + expected_expires_at = now + datetime.timedelta( seconds=300) expected_message_record = { 'project_id': 'fakeproject',