From f21e7cb17826f48917d3b267203c7d90f01cae8a Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Sun, 21 Jun 2015 22:34:46 -0700 Subject: [PATCH] Cells: add in missing unit test for get_by_uuid Adds in a missing unit tests to check the flow when the requested uuid does not exists. TrivialFix Change-Id: I8b68761197021e08d13324e9686c0610aed446ad --- nova/tests/unit/objects/test_cell_mapping.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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()