diff options
| author | Zhongyue Luo <lzyeval@gmail.com> | 2012-05-21 13:17:58 +0800 |
|---|---|---|
| committer | Zhongyue Luo <lzyeval@gmail.com> | 2012-05-23 22:02:04 +0800 |
| commit | 8c34089997d6dd6491a779964792ce4a85f523fa (patch) | |
| tree | fd37e1e220f9a184f2b9404c578e4e1256597731 /nova/tests | |
| parent | 7e15d4e28f98e13f0ea7399787c50839139d8492 (diff) | |
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
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_api.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index fc78e1d4c..b0367dd8f 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') |
