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