From e91c3d141c957485dcb66c73e84b41b775e4268b Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 17 Jun 2013 15:05:17 -0700 Subject: Make NovaObject support extra attributes in items() An object could define a field as a property, which needs to get included in items() and iteritems() for dict compatibility. Related to blueprint unified-object-model Change-Id: I2ca665e70fc6d3c9664ae7a74dffd99a56f6a8c1 --- nova/tests/objects/test_instance.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/objects/test_instance.py b/nova/tests/objects/test_instance.py index a9238a924..91c59f6ff 100644 --- a/nova/tests/objects/test_instance.py +++ b/nova/tests/objects/test_instance.py @@ -212,6 +212,15 @@ class _TestInstanceObject(object): inst.info_cache.network_info = 'bar' inst.save() + def test_iteritems_with_extra_attrs(self): + self.stubs.Set(instance.Instance, 'name', 'foo') + inst = instance.Instance() + inst.uuid = 'fake-uuid' + self.assertEqual(inst.items(), + {'uuid': 'fake-uuid', + 'name': 'foo', + }.items()) + class TestInstanceObject(test_objects._LocalTest, _TestInstanceObject): -- cgit