Merge branch 'mptt'
authorStephen Burrows <stephen.r.burrows@gmail.com>
Mon, 29 Nov 2010 18:25:19 +0000 (13:25 -0500)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Mon, 29 Nov 2010 18:25:19 +0000 (13:25 -0500)
Conflicts:
tests.py

1  2 
tests.py

diff --cc tests.py
+++ b/tests.py
@@@ -1,8 -1,7 +1,9 @@@
  from django.test import TestCase
  from django import template
  from django.conf import settings
+ from django.db import connection
 +from django.template import loader
 +from django.template.loaders import cached
  from philo.exceptions import AncestorDoesNotExist
  from philo.models import Node, Page, Template
  from philo.contrib.penfield.models import Blog, BlogView, BlogEntry
@@@ -178,23 -114,15 +206,15 @@@ class TreePathTestCase(TestCase)
        
        def test_get_path(self):
                root = Node.objects.get(slug='root')
+               root2 = Node.objects.get(slug='root')
                third = Node.objects.get(slug='third')
-               r1 = Node.objects.get(slug='recursive1')
-               r2 = Node.objects.get(slug='recursive2')
-               pr1 = Node.objects.get(slug='postrecursive1')
-               
-               # Simple case: straight path to None
-               self.assertEqual(root.get_path(), 'root')
-               self.assertEqual(third.get_path(), 'root/never/more/second/third')
-               
-               # Recursive case: Looped path to root None
-               self.assertEqual(r1.get_path(), u'\u2026/recursive1/recursive2/recursive3/recursive1')
-               self.assertEqual(pr1.get_path(), u'\u2026/recursive3/recursive1/recursive2/recursive3/postrecursive1')
-               
-               # Simple error case: straight invalid path
-               self.assertRaises(AncestorDoesNotExist, root.get_path, root=third)
-               self.assertRaises(AncestorDoesNotExist, third.get_path, root=pr1)
-               
-               # Recursive error case
-               self.assertRaises(AncestorDoesNotExist, r1.get_path, root=root)
-               self.assertRaises(AncestorDoesNotExist, pr1.get_path, root=third)
+               second2 = Node.objects.get(slug='second2')
+               fifth = Node.objects.get(slug='fifth')
+               e = AncestorDoesNotExist
+               
+               self.assertQueryLimit(0, 'root', callable=root.get_path)
+               self.assertQueryLimit(0, '', root2, callable=root.get_path)
+               self.assertQueryLimit(1, 'root/second/third', callable=third.get_path)
+               self.assertQueryLimit(1, 'second/third', root, callable=third.get_path)
+               self.assertQueryLimit(1, e, third, callable=second2.get_path)
 -              self.assertQueryLimit(1, '? - ?', root, ' - ', 'title', callable=third.get_path)
++              self.assertQueryLimit(1, '? - ?', root, ' - ', 'title', callable=third.get_path)