From a87819392ca42159773eda61defa01abbda0a2b9 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Tue, 5 Feb 2013 11:00:03 -0800 Subject: Allow to_primitive to ignore datetimes In preparation for having nova.db.api not return any sqlalchemy objects. nova.db.api will return only primitives, except for datetime.datetime objects. Uses functools.partial to make code DRYING Partially implements bp db-api-cleanup Change-Id: I9980d8c4e20b05bbe734cf90ac209e4e7e89befb --- tests/unit/test_jsonutils.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/unit/test_jsonutils.py') diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py index f618a05..87ac367 100644 --- a/tests/unit/test_jsonutils.py +++ b/tests/unit/test_jsonutils.py @@ -58,6 +58,10 @@ class ToPrimitiveTestCase(utils.BaseTestCase): self.assertEquals(jsonutils.to_primitive(x), '1920-02-03T04:05:06.000007') + def test_datetime_preserve(self): + x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7) + self.assertEquals(jsonutils.to_primitive(x, convert_datetime=False), x) + def test_DateTime(self): x = xmlrpclib.DateTime() x.decode("19710203T04:05:06") -- cgit