Permalink
Browse files

Improved utils_find_selected tests

  • Loading branch information...
1 parent 1e714c6 commit 7d4418f3b234633844494931e602bcd97c271a51 Jonas Obrist committed Dec 31, 2010
Showing with 7 additions and 5 deletions.
  1. +7 −5 cms/tests/menu.py
View
@@ -11,14 +11,16 @@
class MenusTestCase(CMSTestCase):
- def _get_nodes(self):
+ def _get_nodes(self, path='/'):
node1 = NavigationNode('1', '/1/', 1)
node2 = NavigationNode('2', '/2/', 2, 1)
node3 = NavigationNode('3', '/3/', 3, 2)
node4 = NavigationNode('4', '/4/', 4, 2)
node5 = NavigationNode('5', '/5/', 5)
nodes = [node1, node2, node3, node4, node5]
tree = _build_nodes_inner_for_one_menu([n for n in nodes], "test")
+ request = self.get_request(path)
+ menu_pool.apply_modifiers(tree, request)
return tree, nodes
def setUp(self):
@@ -485,12 +487,12 @@ def test_23_utils_mark_descendants(self):
def test_24_utils_find_selected(self):
tree_nodes, flat_nodes = self._get_nodes()
- flat_nodes[3].selected = True
+ node = flat_nodes[0]
selected = find_selected(tree_nodes)
- self.assertEqual(selected, flat_nodes[3])
+ self.assertEqual(selected, node)
+ selected = find_selected([])
+ self.assertEqual(selected, None)
def test_25_utils_cut_levels(self):
- request = self.get_request('/')
tree_nodes, flat_nodes = self._get_nodes()
- menu_pool.apply_modifiers(tree_nodes, request)
self.assertEqual(cut_levels(tree_nodes, 1), [flat_nodes[1]])

0 comments on commit 7d4418f

Please sign in to comment.