summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-01-14 23:30:17 +0000
committerRamiro Morales <cramm0@gmail.com>2011-01-14 23:30:17 +0000
commit74a61e35b82c8823ec73da5eb23c97e6e1724f06 (patch)
treed90c5f09b6c5ab71029f49d0a6881e5cba0f3452 /tests
parenteb9ebb1931de3b41b7cfe9b48e1f7bfa506d3c4e (diff)
[1.2.X] Fixed #14948 -- Fixed a couple of cases where invalid model classes were passed to the database router when collecting reverse foreign key and many to many relationships. Thanks shell_dweller for the report and Harm Geerts for the patch.
This also enhances tests added in r15186. Code in SVN trunk doesn't suffer from this problem because it was refactored in r14507. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15207 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/multiple_database/tests.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index c0bcedf0aa..052396bd75 100644
--- a/tests/regressiontests/multiple_database/tests.py
+++ b/tests/regressiontests/multiple_database/tests.py
@@ -1739,7 +1739,7 @@ class ModelMetaRouter(object):
if not hasattr(model, '_meta'):
raise ValueError
-class RouterM2MThroughTestCase(TestCase):
+class RouterModelArgumentTestCase(TestCase):
multi_db = True
def setUp(self):
@@ -1749,7 +1749,7 @@ class RouterM2MThroughTestCase(TestCase):
def tearDown(self):
router.routers = self.old_routers
- def test_m2m_through(self):
+ def test_m2m_collection(self):
b = Book.objects.create(title="Pro Django",
published=datetime.date(2008, 12, 16))
@@ -1760,3 +1760,13 @@ class RouterM2MThroughTestCase(TestCase):
b.authors.remove(p)
# test clear
b.authors.clear()
+ # test setattr
+ b.authors = [p]
+ # Test M2M collection (_collect_sub_objects() in Django <= 1.2.X)
+ b.delete()
+
+ def test_foreignkey_collection(self):
+ person = Person.objects.create(name='Bob')
+ pet = Pet.objects.create(owner=person, name='Wart')
+ # Test related FK collection (_collect_sub_objects() in Django <= 1.2.X)
+ person.delete()