Author: ramiro
Date: 2011-01-13 21:53:01 -0600 (Thu, 13 Jan 2011)
New Revision: 15202

Modified:
   
django/branches/releases/1.2.X/tests/regressiontests/multiple_database/tests.py
Log:
[1.2.X] Enhanced tests for r14857 added in r15185. Refs #14870. Thanks Harm 
Geerts.

Backport of [15201] from trunk.

Modified: 
django/branches/releases/1.2.X/tests/regressiontests/multiple_database/tests.py
===================================================================
--- 
django/branches/releases/1.2.X/tests/regressiontests/multiple_database/tests.py 
    2011-01-14 03:43:10 UTC (rev 15201)
+++ 
django/branches/releases/1.2.X/tests/regressiontests/multiple_database/tests.py 
    2011-01-14 03:53:01 UTC (rev 15202)
@@ -1698,13 +1698,41 @@
     def tearDown(self):
         router.routers = self.old_routers
 
-    def test_attribute_error(self):
+    def test_attribute_error_read(self):
         "Check that the AttributeError from AttributeErrorRouter bubbles up"
+        router.routers = [] # Reset routers so we can save a Book instance
+        b = Book.objects.create(title="Pro Django",
+                                published=datetime.date(2008, 12, 16))
+        router.routers = [AttributeErrorRouter()] # Install our router
+        self.assertRaises(AttributeError, Book.objects.get, pk=b.pk)
+
+    def test_attribute_error_save(self):
+        "Check that the AttributeError from AttributeErrorRouter bubbles up"
         dive = Book()
         dive.title="Dive into Python"
         dive.published = datetime.date(2009, 5, 4)
         self.assertRaises(AttributeError, dive.save)
 
+    def test_attribute_error_delete(self):
+        "Check that the AttributeError from AttributeErrorRouter bubbles up"
+        router.routers = [] # Reset routers so we can save our Book, Person 
instances
+        b = Book.objects.create(title="Pro Django",
+                                published=datetime.date(2008, 12, 16))
+        p = Person.objects.create(name="Marty Alchin")
+        b.authors = [p]
+        b.editor = p
+        router.routers = [AttributeErrorRouter()] # Install our router
+        self.assertRaises(AttributeError, b.delete)
+
+    def test_attribute_error_m2m(self):
+        "Check that the AttributeError from AttributeErrorRouter bubbles up"
+        router.routers = [] # Reset routers so we can save our Book, Person 
instances
+        b = Book.objects.create(title="Pro Django",
+                                published=datetime.date(2008, 12, 16))
+        p = Person.objects.create(name="Marty Alchin")
+        router.routers = [AttributeErrorRouter()] # Install our router
+        self.assertRaises(AttributeError, setattr, b, 'authors', [p])
+
 class ModelMetaRouter(object):
     "A router to ensure model arguments are real model classes"
     def db_for_write(self, model, **hints):

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to