summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-06-17 15:05:17 -0700
committerDan Smith <danms@us.ibm.com>2013-06-17 15:11:16 -0700
commite91c3d141c957485dcb66c73e84b41b775e4268b (patch)
tree969bed89cd4482d0f98644cb75ddfed03c1dd2e3 /nova/tests
parent328b347cd058f1c87d7e32a18d9decc0ba517266 (diff)
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
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/objects/test_instance.py9
1 files changed, 9 insertions, 0 deletions
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):