From e4e0d37f8a487d562d95a1ab37b4a90d861eb1d5 Mon Sep 17 00:00:00 2001 From: Matthew Sherborne Date: Tue, 12 Mar 2013 11:24:20 +1000 Subject: Fix behaviour of split_cell_and_item If you try to split a cell and item, with no path!to!cell@ in it, it'll now return None for the cell, instead causing a ValueError when trying to split the result. Change-Id: I228b9f3b0f63f8c7a6004b3206f5312ed2a878bc Fixes: bug #1153841 --- nova/tests/cells/test_cells_utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/cells/test_cells_utils.py b/nova/tests/cells/test_cells_utils.py index 84f60a796..871df0372 100644 --- a/nova/tests/cells/test_cells_utils.py +++ b/nova/tests/cells/test_cells_utils.py @@ -80,3 +80,26 @@ class CellsUtilsTestCase(test.TestCase): {'changes-since': 'fake-updated-since', 'project_id': 'fake-project'}) self.assertEqual(call_info['shuffle'], 2) + + def test_split_cell_and_item(self): + path = 'australia', 'queensland', 'gold_coast' + cell = cells_utils._PATH_CELL_SEP.join(path) + item = 'host_5' + together = cells_utils.cell_with_item(cell, item) + self.assertEqual(cells_utils._CELL_ITEM_SEP.join([cell, item]), + together) + + # Test normal usage + result_cell, result_item = cells_utils.split_cell_and_item(together) + self.assertEqual(cell, result_cell) + self.assertEqual(item, result_item) + + # Test with no cell + cell = None + together = cells_utils.cell_with_item(cell, item) + self.assertEqual(item, together) + print together + result_cell, result_item = cells_utils.split_cell_and_item(together) + print result_cell, result_item + self.assertEqual(cell, result_cell) + self.assertEqual(item, result_item) -- cgit