Commits

Gustavo Picon committed c6d9e33

updated tests to reload nodes after the tree is altered in all tree models, not only NS

Comments (0)

Files changed (1)

treebeard/tests.py

         node = self.model.objects.get(desc=u'231')
         self.model.load_bulk(BASE_DATA, node)
 
-        # this is ONLY needed by the nested set tree model, the rgt value of
-        # the node was updated in a raw query, and it must be updated in
-        # django's object
-        if self.model in (NS_TestNode, NS_TestNode_Proxy):
-            node = self.model.objects.get(pk=node.id)
+        # the tree was modified by load_bulk, so we reload our node object
+        node = self.model.objects.get(pk=node.id)
 
         got = [(o.desc, o.get_depth(), o.get_children_count())
                 for o in self.model.get_tree(node)]
         node = self.model.objects.get(desc=u'231')
         self.model.load_bulk(BASE_DATA, node)
 
-        # this is ONLY needed by the nested set tree model, the rgt value of
-        # the node was updated in a raw query, and it must be updated in
-        # django's object
-        if self.model in (NS_TestNode, NS_TestNode_Proxy):
-            node = self.model.objects.get(pk=node.id)
+        # the tree was modified by load_bulk, so we reload our node object
+        node = self.model.objects.get(pk=node.id)
 
         got = self.model.dump_bulk(node, False)
         expected = [{'data':{'desc':u'231'}, 'children':BASE_DATA}]
         for node in root_nodes[1:]:
 
             # because raw queries don't update django objects
-            if self.sorted_model == NS_TestNodeSorted:
-                node = self.sorted_model.objects.get(pk=node.id)
-                target = self.sorted_model.objects.get(pk=target.id)
+            node = self.sorted_model.objects.get(pk=node.id)
+            target = self.sorted_model.objects.get(pk=target.id)
 
             node.move(target, 'sorted-child')
         expected = [(1, 4, u'bcd', 1, 7),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.