From d030e29f5b0ba215789739e443f25ca1c80bc3da Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 20 Jul 2012 10:45:04 -0400 Subject: Include name in a primitive Instance. This ensures that the name of an instance will be present in the result of jsonutils.to_primitive(Instance). The name isn't a column. It's a property that gets generated dynamically by the Instance class. Part of blueprint no-db-messaging. Change-Id: I45914ed55f2c037ee2efd7775bd57fbde36a2116 --- nova/tests/compute/test_rpcapi.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index d1d633023..96b103393 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -20,7 +20,9 @@ Unit Tests for nova.compute.rpcapi from nova.compute import rpcapi as compute_rpcapi from nova import context +from nova import db from nova import flags +from nova.openstack.common import jsonutils from nova.openstack.common import rpc from nova import test @@ -31,17 +33,18 @@ FLAGS = flags.FLAGS class ComputeRpcAPITestCase(test.TestCase): def setUp(self): - self.fake_instance = { - 'uuid': 'fake_uuid', - 'host': 'fake_host', - 'name': 'fake_name', - 'id': 'fake_id', - } + self.context = context.get_admin_context() + inst = db.instance_create(self.context, {'host': 'fake_host', + 'instance_type_id': 1}) + self.fake_instance = jsonutils.to_primitive(inst) super(ComputeRpcAPITestCase, self).setUp() def tearDown(self): super(ComputeRpcAPITestCase, self).tearDown() + def test_serialized_instance_has_name(self): + self.assertTrue('name' in self.fake_instance) + def _test_compute_api(self, method, rpc_method, **kwargs): ctxt = context.RequestContext('fake_user', 'fake_project') if 'rpcapi_class' in kwargs: -- cgit