Use utils.parse_strtime rather than datetime.strptime
Fixes bug #1002130 Fix direct use of datetime.strptime to utilize utils.parse_strtime Change-Id: Ibb25a1fdae0836f046aa3cdee3190a24db8d7aa5
This commit is contained in:
@@ -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(conv(time_to_convert), '2011-02-21T20:14:10.634Z')
|
||||||
self.assertEqual(
|
|
||||||
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(conv(time_to_convert), '2011-02-21T19:56:18.000Z')
|
||||||
self.assertEqual(
|
|
||||||
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')
|
||||||
|
Reference in New Issue
Block a user