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
This commit is contained in:
parent
9f622e2a50
commit
902a66e53d
@ -33,11 +33,12 @@ class MessageApiTest(test.TestCase):
|
|||||||
self.ctxt = context.RequestContext('admin', 'fakeproject', True)
|
self.ctxt = context.RequestContext('admin', 'fakeproject', True)
|
||||||
self.ctxt.request_id = 'fakerequestid'
|
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)
|
CONF.set_override('message_ttl', 300)
|
||||||
timeutils.set_time_override()
|
now = datetime.datetime.utcnow()
|
||||||
self.addCleanup(timeutils.clear_time_override)
|
mock_utcnow.return_value = now
|
||||||
expected_expires_at = timeutils.utcnow() + datetime.timedelta(
|
expected_expires_at = now + datetime.timedelta(
|
||||||
seconds=300)
|
seconds=300)
|
||||||
expected_message_record = {
|
expected_message_record = {
|
||||||
'project_id': 'fakeproject',
|
'project_id': 'fakeproject',
|
||||||
|
Loading…
Reference in New Issue
Block a user