From 14fcded53ded17a1c10325453c2e04458955301f Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Tue, 8 Jan 2013 21:46:01 +0000 Subject: Clarify the DBApi object in cells fakes Adds a docstring and makes instance_get_by_uuid() raise by default. It's only used as a stubbing point, but returning 'None' is not really valid and having it raise might save someone some confusion in the future. Change-Id: Ie3fa333288f9c0263ead69c2d307101b8583dea7 --- nova/tests/cells/fakes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nova/tests/cells/fakes.py b/nova/tests/cells/fakes.py index e1f3b6e70..e996cbe13 100644 --- a/nova/tests/cells/fakes.py +++ b/nova/tests/cells/fakes.py @@ -22,6 +22,7 @@ from nova.cells import messaging from nova.cells import state as cells_state import nova.db from nova.db import base +from nova import exception from nova.openstack.common import cfg CONF = cfg.CONF @@ -43,6 +44,10 @@ CELL_NAME_TO_STUB_INFO = {} class FakeDBApi(object): + """Cells uses a different DB in each cell. This means in order to + stub out things differently per cell, I need to create a fake DBApi + object that is instantiated by each fake cell. + """ def __init__(self, cell_db_entries): self.cell_db_entries = cell_db_entries @@ -58,8 +63,8 @@ class FakeDBApi(object): def instance_get_all_by_filters(self, ctxt, *args, **kwargs): return [] - def instance_get_by_uuid(self, ctxt, *args, **kwargs): - return None + def instance_get_by_uuid(self, ctxt, instance_uuid): + raise exception.InstanceNotFound(instance_id=instance_uuid) class FakeCellsDriver(driver.BaseCellsDriver): -- cgit