From f84491971d560df3ca06b39e648350bef2bb0eb0 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Mon, 21 May 2012 13:17:58 +0800 Subject: [PATCH] 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 --- nova/tests/test_api.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index fc78e1d4..b0367dd8 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -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')