Merge "Use utils.parse_strtime rather than datetime.strptime"

This commit is contained in:
Jenkins
2012-05-23 17:31:38 +00:00
committed by Gerrit Code Review

View File

@@ -18,7 +18,6 @@
"""Unit tests for the API endpoint"""
import datetime
import httplib
import random
import StringIO
@@ -37,6 +36,7 @@ from nova.compute import api as compute_api
from nova import context
from nova import exception
from nova import test
from nova import utils
class FakeHttplibSocket(object):
@@ -249,19 +249,13 @@ class ApiEc2TestCase(test.TestCase):
"""
conv = apirequest._database_to_isoformat
# sqlite database representation with microseconds
time_to_convert = datetime.datetime.strptime(
"2011-02-21 20:14:10.634276",
"%Y-%m-%d %H:%M:%S.%f")
self.assertEqual(
conv(time_to_convert),
'2011-02-21T20:14:10.634Z')
time_to_convert = utils.parse_strtime("2011-02-21 20:14:10.634276",
"%Y-%m-%d %H:%M:%S.%f")
self.assertEqual(conv(time_to_convert), '2011-02-21T20:14:10.634Z')
# mysqlite database representation
time_to_convert = datetime.datetime.strptime(
"2011-02-21 19:56:18",
"%Y-%m-%d %H:%M:%S")
self.assertEqual(
conv(time_to_convert),
'2011-02-21T19:56:18.000Z')
time_to_convert = utils.parse_strtime("2011-02-21 19:56:18",
"%Y-%m-%d %H:%M:%S")
self.assertEqual(conv(time_to_convert), '2011-02-21T19:56:18.000Z')
def test_xmlns_version_matches_request_version(self):
self.expect_http(api_version='2010-10-30')