diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-07-20 10:45:04 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-07-25 19:48:30 -0400 |
| commit | d030e29f5b0ba215789739e443f25ca1c80bc3da (patch) | |
| tree | 842ceced478a9215cafaa2c82980bbb7df37ead3 /nova/tests | |
| parent | eebc64f949ccb2acb7462efc18f538f1827985af (diff) | |
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
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_rpcapi.py | 15 |
1 files changed, 9 insertions, 6 deletions
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: |
