summaryrefslogtreecommitdiff
path: root/nova/tests
diff options
context:
space:
mode:
authorMatthew Sherborne <msherborne@gmail.com>2013-03-12 11:24:20 +1000
committerMatthew Sherborne <msherborne@gmail.com>2013-03-12 13:25:31 +1000
commite4e0d37f8a487d562d95a1ab37b4a90d861eb1d5 (patch)
treee3811a529df061c1d13ba8d12adb8d1ab97e482a /nova/tests
parent782dd69de4c6661eeb889b4e5b3b1b8df9d228b6 (diff)
downloadnova-e4e0d37f8a487d562d95a1ab37b4a90d861eb1d5.tar.gz
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
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/cells/test_cells_utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/tests/cells/test_cells_utils.py b/nova/tests/cells/test_cells_utils.py
index 84f60a796c..871df0372e 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)