From 15c82cc9020e47ea5c2c8747de0a27bc0bc3d70d Mon Sep 17 00:00:00 2001 From: "Davanum Srinivas (dims)" Date: Mon, 1 Jun 2015 19:35:55 +0000 Subject: [PATCH] Revert "jsonutils: replace strtime() usage with isoformat()" This is a wire format change that the projects are not ready for yet (example Nova). We should do this as part of a major version bump (2.x) with ample time for folks to move up. Nova review to prepare the Nova code base for this change: Ib7e60ed94edd1eb409baf8c29c61237d85944787 This reverts commit 5b0827a3df584b3e26bb44e5358cc28ac4a91636. Change-Id: Ic4bf047b40c1dad2f8d2bc0afda934e47dba1f9d --- oslo_serialization/jsonutils.py | 3 ++- oslo_serialization/tests/test_jsonutils.py | 9 +-------- tests/test_jsonutils.py | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/oslo_serialization/jsonutils.py b/oslo_serialization/jsonutils.py index f24adbe..3d326e7 100644 --- a/oslo_serialization/jsonutils.py +++ b/oslo_serialization/jsonutils.py @@ -57,6 +57,7 @@ from oslo_utils import encodeutils from oslo_utils import importutils +from oslo_utils import timeutils import six import six.moves.xmlrpc_client as xmlrpclib @@ -110,7 +111,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, if isinstance(value, datetime.datetime): if convert_datetime: - return value.isoformat() + return timeutils.strtime(value) else: return value diff --git a/oslo_serialization/tests/test_jsonutils.py b/oslo_serialization/tests/test_jsonutils.py index 18bdc36..9709cb6 100644 --- a/oslo_serialization/tests/test_jsonutils.py +++ b/oslo_serialization/tests/test_jsonutils.py @@ -17,7 +17,6 @@ import datetime import json -import iso8601 import mock import netaddr from oslo_i18n import fixture @@ -136,12 +135,6 @@ def test_datetime(self): self.assertEqual(jsonutils.to_primitive(x), '1920-02-03T04:05:06.000007') - def test_datetime_timezone(self): - x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7, - tzinfo=iso8601.iso8601.UTC) - self.assertEqual(jsonutils.to_primitive(x), - '1920-02-03T04:05:06.000007+00:00') - def test_datetime_preserve(self): x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7) self.assertEqual(jsonutils.to_primitive(x, convert_datetime=False), x) @@ -150,7 +143,7 @@ def test_DateTime(self): x = xmlrpclib.DateTime() x.decode("19710203T04:05:06") self.assertEqual(jsonutils.to_primitive(x), - '1971-02-03T04:05:06') + '1971-02-03T04:05:06.000000') def test_iter(self): class IterClass(object): diff --git a/tests/test_jsonutils.py b/tests/test_jsonutils.py index a150b43..d2a7950 100644 --- a/tests/test_jsonutils.py +++ b/tests/test_jsonutils.py @@ -173,7 +173,7 @@ def test_DateTime(self): x = xmlrpclib.DateTime() x.decode("19710203T04:05:06") self.assertEqual(jsonutils.to_primitive(x), - '1971-02-03T04:05:06') + '1971-02-03T04:05:06.000000') def test_iter(self): class IterClass(object):