summaryrefslogtreecommitdiff
path: root/tests/regressiontests/multiple_database
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-01-14 03:43:10 +0000
committerRamiro Morales <cramm0@gmail.com>2011-01-14 03:43:10 +0000
commit7916c754aa91f83a96b2b8b3c54a2f32bdeca740 (patch)
treee263df016f78e376e34e5e04eea4e26aa4f99979 /tests/regressiontests/multiple_database
parentb7ce6b03bbb23129880e7d01f845f25ec8af8c89 (diff)
Enhanced tests for r14857 added in r15185. Refs #14870. Thanks Harm Geerts.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15201 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/multiple_database')
-rw-r--r--tests/regressiontests/multiple_database/tests.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index 69bb7efd85..a0a05b72b8 100644
--- a/tests/regressiontests/multiple_database/tests.py
+++ b/tests/regressiontests/multiple_database/tests.py
@@ -1810,13 +1810,41 @@ class RouterAttributeErrorTestCase(TestCase):
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):