From 4cd2945740d37119be57f35e41afe3f2ab999114 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Tue, 10 Apr 2012 13:35:30 +0100 Subject: [PATCH] Fix expired token tests Fixes bug #983800 The expiration timestamps are expressed in UTC time, so ensure: 1) The timestamp of the token created by the test is UTC time (i.e. utcnow() vs now()) 2) The expiration check in the dummy memcache client properly accounts for UTC (i.e. utctimetuple() vs timetuple()) Change-Id: Ie7356456f79ab5a8070a79771bb7d210b1cedd47 --- tests/test_backend.py | 2 +- tests/test_backend_memcache.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_backend.py b/tests/test_backend.py index 3bc743e05f..d7079ba614 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -326,7 +326,7 @@ class TokenTests(object): def test_expired_token(self): token_id = uuid.uuid4().hex - expire_time = datetime.datetime.now() - datetime.timedelta(minutes=1) + expire_time = datetime.datetime.utcnow() - datetime.timedelta(minutes=1) data = {'id': token_id, 'a': 'b', 'expires': expire_time} data_ref = self.token_api.create_token(token_id, data) self.assertDictEqual(data_ref, data) diff --git a/tests/test_backend_memcache.py b/tests/test_backend_memcache.py index 60112a6fea..2c07580b86 100644 --- a/tests/test_backend_memcache.py +++ b/tests/test_backend_memcache.py @@ -42,7 +42,7 @@ class MemcacheClient(object): """Retrieves the value for a key or None.""" self.check_key(key) obj = self.cache.get(key) - now = time.mktime(datetime.datetime.utcnow().timetuple()) + now = time.mktime(datetime.datetime.utcnow().utctimetuple()) if obj and (obj[1] == 0 or obj[1] > now): return obj[0] else: