summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZhongyue Luo <lzyeval@gmail.com>2012-06-05 09:11:44 +0800
committerZhongyue Luo <lzyeval@gmail.com>2012-06-29 06:38:49 +0800
commitc79d93bfbc8a79617a6d3ef4e36fb5de55217d02 (patch)
tree1940868376325627fe4f16091d4b8e784e0c69fe /tests
parent8cd73c75cec35d4df49891ee4c36102b4c8d96ff (diff)
downloadkeystone-c79d93bfbc8a79617a6d3ef4e36fb5de55217d02.tar.gz
keystone-c79d93bfbc8a79617a6d3ef4e36fb5de55217d02.tar.xz
keystone-c79d93bfbc8a79617a6d3ef4e36fb5de55217d02.zip
Keystone should use openstack.common.timeutils
Implements blueprint use-common-timeutils 1. Edit openstack-common.conf and import keystone/openstack/common/timeutils.py 2. Replace datetime.utcnow with timeutils.utcnow 3. Replace utils.isotime with timeutils.isotime 4. Remove utils.isotime in common/utils.py and datetime related unittest Change-Id: I4f5a63a368fde8787a0dc0a817c940de685b9ca2
Diffstat (limited to 'tests')
-rw-r--r--tests/test_backend.py4
-rw-r--r--tests/test_backend_memcache.py6
-rw-r--r--tests/test_utils.py9
3 files changed, 5 insertions, 14 deletions
diff --git a/tests/test_backend.py b/tests/test_backend.py
index 85cb4c31..83aabfda 100644
--- a/tests/test_backend.py
+++ b/tests/test_backend.py
@@ -18,6 +18,7 @@ import datetime
import uuid
from keystone import exception
+from keystone.openstack.common import timeutils
class IdentityTests(object):
@@ -553,8 +554,7 @@ class TokenTests(object):
def test_expired_token(self):
token_id = uuid.uuid4().hex
- expire_time = datetime.datetime.utcnow() - datetime.timedelta(
- minutes=1)
+ expire_time = timeutils.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 2c07580b..f18cc9ca 100644
--- a/tests/test_backend_memcache.py
+++ b/tests/test_backend_memcache.py
@@ -14,13 +14,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import datetime
-import time
import uuid
import memcache
+from keystone.common import utils
from keystone import exception
+from keystone.openstack.common import timeutils
from keystone import test
from keystone.token.backends import memcache as token_memcache
@@ -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().utctimetuple())
+ now = utils.unixtime(timeutils.utcnow())
if obj and (obj[1] == 0 or obj[1] > now):
return obj[0]
else:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 52efafcb..0c9c7757 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -29,8 +29,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import datetime
-
from keystone import test
from keystone.common import utils
@@ -60,13 +58,6 @@ class UtilsTestCase(test.TestCase):
self.assertTrue(utils.check_password(password, hashed))
self.assertFalse(utils.check_password(wrong, hashed))
- def test_isotime(self):
- dt = datetime.datetime(year=1987, month=10, day=13,
- hour=1, minute=2, second=3)
- output = utils.isotime(dt)
- expected = '1987-10-13T01:02:03Z'
- self.assertEqual(output, expected)
-
def test_auth_str_equal(self):
self.assertTrue(utils.auth_str_equal('abc123', 'abc123'))
self.assertFalse(utils.auth_str_equal('a', 'aaaaa'))