mirror of https://github.com/django/django.git
[1.5.x] Use HTML parser to compare html snippets
Backport of 585aa11d23
from master
This commit is contained in:
parent
515cf94b60
commit
95b4f34b5e
|
@ -131,19 +131,17 @@ class TestInline(TestCase):
|
||||||
response = self.client.get('/admin/admin_inlines/capofamiglia/add/')
|
response = self.client.get('/admin/admin_inlines/capofamiglia/add/')
|
||||||
|
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input type="hidden" name="-1-0-id" id="id_-1-0-id" />')
|
'<input type="hidden" name="-1-0-id" id="id_-1-0-id" />', html=True)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input type="hidden" name="-1-0-capo_famiglia" '
|
'<input type="hidden" name="-1-0-capo_famiglia" id="id_-1-0-capo_famiglia" />', html=True)
|
||||||
'id="id_-1-0-capo_famiglia" />')
|
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input id="id_-1-0-name" type="text" class="vTextField" '
|
'<input id="id_-1-0-name" type="text" class="vTextField" '
|
||||||
'name="-1-0-name" maxlength="100" />', html=True)
|
'name="-1-0-name" maxlength="100" />', html=True)
|
||||||
|
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input type="hidden" name="-2-0-id" id="id_-2-0-id" />')
|
'<input type="hidden" name="-2-0-id" id="id_-2-0-id" />', html=True)
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input type="hidden" name="-2-0-capo_famiglia" '
|
'<input type="hidden" name="-2-0-capo_famiglia" id="id_-2-0-capo_famiglia" />', html=True)
|
||||||
'id="id_-2-0-capo_famiglia" />')
|
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
'<input id="id_-2-0-name" type="text" class="vTextField" '
|
'<input id="id_-2-0-name" type="text" class="vTextField" '
|
||||||
'name="-2-0-name" maxlength="100" />', html=True)
|
'name="-2-0-name" maxlength="100" />', html=True)
|
||||||
|
@ -326,7 +324,8 @@ class TestInlinePermissions(TestCase):
|
||||||
# Add permission on inner2s, so we get the inline
|
# Add permission on inner2s, so we get the inline
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
self.assertContains(response, 'Add another Inner2')
|
self.assertContains(response, 'Add another Inner2')
|
||||||
self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
|
'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
|
||||||
def test_inline_change_m2m_add_perm(self):
|
def test_inline_change_m2m_add_perm(self):
|
||||||
permission = Permission.objects.get(codename='add_book', content_type=self.book_ct)
|
permission = Permission.objects.get(codename='add_book', content_type=self.book_ct)
|
||||||
|
@ -345,8 +344,10 @@ class TestInlinePermissions(TestCase):
|
||||||
# We have change perm on books, so we can add/change/delete inlines
|
# We have change perm on books, so we can add/change/delete inlines
|
||||||
self.assertContains(response, '<h2>Author-book relationships</h2>')
|
self.assertContains(response, '<h2>Author-book relationships</h2>')
|
||||||
self.assertContains(response, 'Add another Author-Book Relationship')
|
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" id="id_Author_books-TOTAL_FORMS" '
|
||||||
self.assertContains(response, '<input type="hidden" name="Author_books-0-id" value="%i"' % self.author_book_auto_m2m_intermediate_id)
|
'value="4" name="Author_books-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertContains(response, '<input type="hidden" id="id_Author_books-0-id" '
|
||||||
|
'value="%i" name="Author_books-0-id" />' % self.author_book_auto_m2m_intermediate_id, html=True)
|
||||||
self.assertContains(response, 'id="id_Author_books-0-DELETE"')
|
self.assertContains(response, 'id="id_Author_books-0-DELETE"')
|
||||||
|
|
||||||
def test_inline_change_fk_add_perm(self):
|
def test_inline_change_fk_add_perm(self):
|
||||||
|
@ -357,8 +358,10 @@ class TestInlinePermissions(TestCase):
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
self.assertContains(response, 'Add another Inner2')
|
self.assertContains(response, 'Add another Inner2')
|
||||||
# 3 extra forms only, not the existing instance form
|
# 3 extra forms only, not the existing instance form
|
||||||
self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
self.assertNotContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
|
'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertNotContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
|
||||||
|
'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
|
||||||
|
|
||||||
def test_inline_change_fk_change_perm(self):
|
def test_inline_change_fk_change_perm(self):
|
||||||
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
|
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
|
||||||
|
@ -367,10 +370,13 @@ class TestInlinePermissions(TestCase):
|
||||||
# Change permission on inner2s, so we can change existing but not add new
|
# Change permission on inner2s, so we can change existing but not add new
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
# Just the one form for existing instances
|
# Just the one form for existing instances
|
||||||
self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
|
'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
|
||||||
|
'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
|
||||||
# max-num 0 means we can't add new ones
|
# max-num 0 means we can't add new ones
|
||||||
self.assertContains(response, 'value="0" id="id_inner2_set-MAX_NUM_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-MAX_NUM_FORMS" '
|
||||||
|
'value="0" name="inner2_set-MAX_NUM_FORMS" />', html=True)
|
||||||
|
|
||||||
def test_inline_change_fk_add_change_perm(self):
|
def test_inline_change_fk_add_change_perm(self):
|
||||||
permission = Permission.objects.get(codename='add_inner2', content_type=self.inner_ct)
|
permission = Permission.objects.get(codename='add_inner2', content_type=self.inner_ct)
|
||||||
|
@ -381,9 +387,10 @@ class TestInlinePermissions(TestCase):
|
||||||
# Add/change perm, so we can add new and change existing
|
# Add/change perm, so we can add new and change existing
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
# One form for existing instance and three extra for new
|
# One form for existing instance and three extra for new
|
||||||
self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
|
'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
|
||||||
|
'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
|
||||||
|
|
||||||
def test_inline_change_fk_change_del_perm(self):
|
def test_inline_change_fk_change_del_perm(self):
|
||||||
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
|
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
|
||||||
|
@ -394,8 +401,10 @@ class TestInlinePermissions(TestCase):
|
||||||
# Change/delete perm on inner2s, so we can change/delete existing
|
# Change/delete perm on inner2s, so we can change/delete existing
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
# One form for existing instance only, no new
|
# One form for existing instance only, no new
|
||||||
self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
|
'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
|
||||||
|
'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
|
||||||
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
|
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
|
||||||
|
|
||||||
|
|
||||||
|
@ -410,8 +419,10 @@ class TestInlinePermissions(TestCase):
|
||||||
# All perms on inner2s, so we can add/change/delete
|
# All perms on inner2s, so we can add/change/delete
|
||||||
self.assertContains(response, '<h2>Inner2s</h2>')
|
self.assertContains(response, '<h2>Inner2s</h2>')
|
||||||
# One form for existing instance only, three for new
|
# One form for existing instance only, three for new
|
||||||
self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
|
||||||
self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
|
'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
|
||||||
|
self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
|
||||||
|
'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
|
||||||
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
|
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue