summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2013-02-05 11:00:03 -0800
committerJoe Gordon <jogo@cloudscaling.com>2013-02-07 17:00:05 -0800
commita87819392ca42159773eda61defa01abbda0a2b9 (patch)
treedabb8d0ad9751c590d67e4c5cfeb911d0c6bf375 /tests/unit
parent868a530aa65de371ffae6e0afb271ff96fe1201f (diff)
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
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_jsonutils.py4
1 files changed, 4 insertions, 0 deletions
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")