Author: ramiro
Date: 2011-10-16 19:11:12 -0700 (Sun, 16 Oct 2011)
New Revision: 17001

Modified:
   django/trunk/tests/regressiontests/admin_inlines/tests.py
Log:
Tweaked a tests tweak from r16960 so it uses the right model.

When testing for permission enforcement in the admin for m2m
relationships we were erroneously using the ID of the related model
instead of using the ID of the corresponding automatically created
intermediate model. This manifested as a failure under Oracle but can
fail with any backend if the IDs of both models diverge.

Modified: django/trunk/tests/regressiontests/admin_inlines/tests.py
===================================================================
--- django/trunk/tests/regressiontests/admin_inlines/tests.py   2011-10-17 
00:56:32 UTC (rev 17000)
+++ django/trunk/tests/regressiontests/admin_inlines/tests.py   2011-10-17 
02:11:12 UTC (rev 17001)
@@ -233,7 +233,9 @@
         author = Author.objects.create(pk=1, name=u'The Author')
         book = author.books.create(name=u'The inline Book')
         self.author_change_url = '/admin/admin_inlines/author/%i/' % author.id
-        self.book_id = book.id
+        # Get the ID of the automatically created intermediate model for thw 
Author-Book m2m
+        author_book_auto_m2m_intermediate = 
Author.books.through.objects.get(author=author, book=book)
+        self.author_book_auto_m2m_intermediate_id = 
author_book_auto_m2m_intermediate.pk
 
         holder = Holder2.objects.create(dummy=13)
         inner2 = Inner2.objects.create(dummy=42, holder=holder)
@@ -311,7 +313,7 @@
         self.assertContains(response, '<h2>Author-book relationships</h2>')
         self.assertContains(response, 'Add another Author-Book Relationship')
         self.assertContains(response, 'value="4" 
id="id_Author_books-TOTAL_FORMS"')
-        self.assertContains(response, '<input type="hidden" 
name="Author_books-0-id" value="%i"' % self.book_id)
+        self.assertContains(response, '<input type="hidden" 
name="Author_books-0-id" value="%i"' % 
self.author_book_auto_m2m_intermediate_id)
         self.assertContains(response, 'id="id_Author_books-0-DELETE"')
 
     def test_inline_change_fk_add_perm(self):

-- 
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