Skip to content
This repository
Browse code

Improved utils_find_selected tests

  • Loading branch information...
commit 7d4418f3b234633844494931e602bcd97c271a51 1 parent 1e714c6
Jonas Obrist authored December 31, 2010

Showing 1 changed file with 7 additions and 5 deletions. Show diff stats Hide diff stats

  1. 12  cms/tests/menu.py
12  cms/tests/menu.py
@@ -11,7 +11,7 @@
11 11
 
12 12
 class MenusTestCase(CMSTestCase):
13 13
     
14  
-    def _get_nodes(self):
  14
+    def _get_nodes(self, path='/'):
15 15
         node1 = NavigationNode('1', '/1/', 1)
16 16
         node2 = NavigationNode('2', '/2/', 2, 1)
17 17
         node3 = NavigationNode('3', '/3/', 3, 2)
@@ -19,6 +19,8 @@ def _get_nodes(self):
19 19
         node5 = NavigationNode('5', '/5/', 5)
20 20
         nodes = [node1, node2, node3, node4, node5]
21 21
         tree = _build_nodes_inner_for_one_menu([n for n in nodes], "test")
  22
+        request = self.get_request(path)
  23
+        menu_pool.apply_modifiers(tree, request)
22 24
         return tree, nodes
23 25
 
24 26
     def setUp(self):
@@ -485,12 +487,12 @@ def test_23_utils_mark_descendants(self):
485 487
             
486 488
     def test_24_utils_find_selected(self):
487 489
         tree_nodes, flat_nodes = self._get_nodes()
488  
-        flat_nodes[3].selected = True
  490
+        node = flat_nodes[0]
489 491
         selected = find_selected(tree_nodes)
490  
-        self.assertEqual(selected, flat_nodes[3])
  492
+        self.assertEqual(selected, node)
  493
+        selected = find_selected([])
  494
+        self.assertEqual(selected, None)
491 495
         
492 496
     def test_25_utils_cut_levels(self):
493  
-        request = self.get_request('/')
494 497
         tree_nodes, flat_nodes = self._get_nodes()
495  
-        menu_pool.apply_modifiers(tree_nodes, request)
496 498
         self.assertEqual(cut_levels(tree_nodes, 1), [flat_nodes[1]])

0 notes on commit 7d4418f

Please sign in to comment.
Something went wrong with that request. Please try again.