diff --git a/nova/tests/unit/objects/test_cell_mapping.py b/nova/tests/unit/objects/test_cell_mapping.py index 96e538edbe..1046b8d755 100644 --- a/nova/tests/unit/objects/test_cell_mapping.py +++ b/nova/tests/unit/objects/test_cell_mapping.py @@ -14,6 +14,7 @@ import mock from oslo_utils import uuidutils +from nova import exception from nova import objects from nova.objects import cell_mapping from nova.tests.unit.objects import test_objects @@ -44,6 +45,16 @@ class _TestCellMappingObject(object): uuid_from_db.assert_called_once_with(self.context, db_mapping['uuid']) self.compare_obj(mapping_obj, db_mapping) + @mock.patch.object(cell_mapping.CellMapping, '_get_by_uuid_from_db', + side_effect=exception.CellMappingNotFound(uuid='fake')) + def test_get_by_uuid_invalid(self, uuid_from_db): + db_mapping = get_db_mapping() + self.assertRaises(exception.CellMappingNotFound, + objects.CellMapping().get_by_uuid, + self.context, + db_mapping['uuid']) + uuid_from_db.assert_called_once_with(self.context, db_mapping['uuid']) + @mock.patch.object(cell_mapping.CellMapping, '_create_in_db') def test_create(self, create_in_db): uuid = uuidutils.generate_uuid()