mirror of https://github.com/django/django.git
Fixed a number of tests that were failing in Oracle due to false assumptions about the primary keys of objects.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15779 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d9e61a435a
commit
9e637d3061
|
@ -70,7 +70,7 @@ class DeletionTests(TestCase):
|
|||
'form-TOTAL_FORMS': u'1',
|
||||
'form-INITIAL_FORMS': u'1',
|
||||
'form-MAX_NUM_FORMS': u'0',
|
||||
'form-0-id': u'1',
|
||||
'form-0-id': unicode(poet.id),
|
||||
'form-0-name': u'x' * 1000,
|
||||
}
|
||||
formset = PoetFormSet(data, queryset=Poet.objects.all())
|
||||
|
@ -250,9 +250,9 @@ class ModelFormsetTest(TestCase):
|
|||
'form-TOTAL_FORMS': '2', # the number of forms rendered
|
||||
'form-INITIAL_FORMS': '1', # the number of forms with initial data
|
||||
'form-MAX_NUM_FORMS': '', # the max number of forms
|
||||
'form-0-id': '1',
|
||||
'form-0-id': str(meeting.id),
|
||||
'form-0-name': '2nd Tuesday of the Week Meeting',
|
||||
'form-0-authors': [2, 1, 3, 4],
|
||||
'form-0-authors': [author2.id, author1.id, author3.id, author4.id],
|
||||
'form-1-name': '',
|
||||
'form-1-authors': '',
|
||||
'form-1-DELETE': '',
|
||||
|
@ -457,7 +457,7 @@ class ModelFormsetTest(TestCase):
|
|||
'book_set-TOTAL_FORMS': '3', # the number of forms rendered
|
||||
'book_set-INITIAL_FORMS': '1', # the number of forms with initial data
|
||||
'book_set-MAX_NUM_FORMS': '', # the max number of forms
|
||||
'book_set-0-id': '1',
|
||||
'book_set-0-id': str(book1.id),
|
||||
'book_set-0-title': 'Les Fleurs du Mal',
|
||||
'book_set-1-title': 'Les Paradis Artificiels',
|
||||
'book_set-2-title': '',
|
||||
|
@ -730,14 +730,15 @@ class ModelFormsetTest(TestCase):
|
|||
self.assertTrue(formset.is_valid())
|
||||
saved = formset.save()
|
||||
self.assertEqual(len(saved), 1)
|
||||
owner, = saved
|
||||
self.assertEqual(owner.name, 'Joe Perry')
|
||||
self.assertEqual(owner.place.name, 'Giordanos')
|
||||
owner1, = saved
|
||||
self.assertEqual(owner1.name, 'Joe Perry')
|
||||
self.assertEqual(owner1.place.name, 'Giordanos')
|
||||
|
||||
formset = FormSet(instance=place)
|
||||
self.assertEqual(len(formset.forms), 3)
|
||||
self.assertEqual(formset.forms[0].as_p(),
|
||||
'<p><label for="id_owner_set-0-name">Name:</label> <input id="id_owner_set-0-name" type="text" name="owner_set-0-name" value="Joe Perry" maxlength="100" /><input type="hidden" name="owner_set-0-place" value="1" id="id_owner_set-0-place" /><input type="hidden" name="owner_set-0-auto_id" value="1" id="id_owner_set-0-auto_id" /></p>')
|
||||
'<p><label for="id_owner_set-0-name">Name:</label> <input id="id_owner_set-0-name" type="text" name="owner_set-0-name" value="Joe Perry" maxlength="100" /><input type="hidden" name="owner_set-0-place" value="1" id="id_owner_set-0-place" /><input type="hidden" name="owner_set-0-auto_id" value="%d" id="id_owner_set-0-auto_id" /></p>'
|
||||
% owner1.auto_id)
|
||||
self.assertEqual(formset.forms[1].as_p(),
|
||||
'<p><label for="id_owner_set-1-name">Name:</label> <input id="id_owner_set-1-name" type="text" name="owner_set-1-name" maxlength="100" /><input type="hidden" name="owner_set-1-place" value="1" id="id_owner_set-1-place" /><input type="hidden" name="owner_set-1-auto_id" id="id_owner_set-1-auto_id" /></p>')
|
||||
self.assertEqual(formset.forms[2].as_p(),
|
||||
|
@ -747,7 +748,7 @@ class ModelFormsetTest(TestCase):
|
|||
'owner_set-TOTAL_FORMS': '3',
|
||||
'owner_set-INITIAL_FORMS': '1',
|
||||
'owner_set-MAX_NUM_FORMS': '',
|
||||
'owner_set-0-auto_id': u'1',
|
||||
'owner_set-0-auto_id': unicode(owner1.auto_id),
|
||||
'owner_set-0-name': u'Joe Perry',
|
||||
'owner_set-1-auto_id': '',
|
||||
'owner_set-1-name': u'Jack Berry',
|
||||
|
@ -758,9 +759,9 @@ class ModelFormsetTest(TestCase):
|
|||
self.assertTrue(formset.is_valid())
|
||||
saved = formset.save()
|
||||
self.assertEqual(len(saved), 1)
|
||||
owner, = saved
|
||||
self.assertEqual(owner.name, 'Jack Berry')
|
||||
self.assertEqual(owner.place.name, 'Giordanos')
|
||||
owner2, = saved
|
||||
self.assertEqual(owner2.name, 'Jack Berry')
|
||||
self.assertEqual(owner2.place.name, 'Giordanos')
|
||||
|
||||
# Ensure a custom primary key that is a ForeignKey or OneToOneField get rendered for the user to choose.
|
||||
|
||||
|
@ -769,19 +770,21 @@ class ModelFormsetTest(TestCase):
|
|||
self.assertEqual(formset.forms[0].as_p(),
|
||||
'<p><label for="id_form-0-owner">Owner:</label> <select name="form-0-owner" id="id_form-0-owner">\n'
|
||||
'<option value="" selected="selected">---------</option>\n'
|
||||
'<option value="1">Joe Perry at Giordanos</option>\n'
|
||||
'<option value="2">Jack Berry at Giordanos</option>\n'
|
||||
'<option value="%d">Joe Perry at Giordanos</option>\n'
|
||||
'<option value="%d">Jack Berry at Giordanos</option>\n'
|
||||
'</select></p>\n'
|
||||
'<p><label for="id_form-0-age">Age:</label> <input type="text" name="form-0-age" id="id_form-0-age" /></p>')
|
||||
'<p><label for="id_form-0-age">Age:</label> <input type="text" name="form-0-age" id="id_form-0-age" /></p>'
|
||||
% (owner1.auto_id, owner2.auto_id))
|
||||
|
||||
owner = Owner.objects.get(name=u'Joe Perry')
|
||||
owner1 = Owner.objects.get(name=u'Joe Perry')
|
||||
FormSet = inlineformset_factory(Owner, OwnerProfile, max_num=1, can_delete=False)
|
||||
self.assertEqual(FormSet.max_num, 1)
|
||||
|
||||
formset = FormSet(instance=owner)
|
||||
formset = FormSet(instance=owner1)
|
||||
self.assertEqual(len(formset.forms), 1)
|
||||
self.assertEqual(formset.forms[0].as_p(),
|
||||
'<p><label for="id_ownerprofile-0-age">Age:</label> <input type="text" name="ownerprofile-0-age" id="id_ownerprofile-0-age" /><input type="hidden" name="ownerprofile-0-owner" value="1" id="id_ownerprofile-0-owner" /></p>')
|
||||
'<p><label for="id_ownerprofile-0-age">Age:</label> <input type="text" name="ownerprofile-0-age" id="id_ownerprofile-0-age" /><input type="hidden" name="ownerprofile-0-owner" value="%d" id="id_ownerprofile-0-owner" /></p>'
|
||||
% owner1.auto_id)
|
||||
|
||||
data = {
|
||||
'ownerprofile-TOTAL_FORMS': '1',
|
||||
|
@ -790,32 +793,33 @@ class ModelFormsetTest(TestCase):
|
|||
'ownerprofile-0-owner': '',
|
||||
'ownerprofile-0-age': u'54',
|
||||
}
|
||||
formset = FormSet(data, instance=owner)
|
||||
formset = FormSet(data, instance=owner1)
|
||||
self.assertTrue(formset.is_valid())
|
||||
saved = formset.save()
|
||||
self.assertEqual(len(saved), 1)
|
||||
profile1, = saved
|
||||
self.assertEqual(profile1.owner, owner)
|
||||
self.assertEqual(profile1.owner, owner1)
|
||||
self.assertEqual(profile1.age, 54)
|
||||
|
||||
formset = FormSet(instance=owner)
|
||||
formset = FormSet(instance=owner1)
|
||||
self.assertEqual(len(formset.forms), 1)
|
||||
self.assertEqual(formset.forms[0].as_p(),
|
||||
'<p><label for="id_ownerprofile-0-age">Age:</label> <input type="text" name="ownerprofile-0-age" value="54" id="id_ownerprofile-0-age" /><input type="hidden" name="ownerprofile-0-owner" value="1" id="id_ownerprofile-0-owner" /></p>')
|
||||
'<p><label for="id_ownerprofile-0-age">Age:</label> <input type="text" name="ownerprofile-0-age" value="54" id="id_ownerprofile-0-age" /><input type="hidden" name="ownerprofile-0-owner" value="%d" id="id_ownerprofile-0-owner" /></p>'
|
||||
% owner1.auto_id)
|
||||
|
||||
data = {
|
||||
'ownerprofile-TOTAL_FORMS': '1',
|
||||
'ownerprofile-INITIAL_FORMS': '1',
|
||||
'ownerprofile-MAX_NUM_FORMS': '1',
|
||||
'ownerprofile-0-owner': u'1',
|
||||
'ownerprofile-0-owner': unicode(owner1.auto_id),
|
||||
'ownerprofile-0-age': u'55',
|
||||
}
|
||||
formset = FormSet(data, instance=owner)
|
||||
formset = FormSet(data, instance=owner1)
|
||||
self.assertTrue(formset.is_valid())
|
||||
saved = formset.save()
|
||||
self.assertEqual(len(saved), 1)
|
||||
profile1, = saved
|
||||
self.assertEqual(profile1.owner, owner)
|
||||
self.assertEqual(profile1.owner, owner1)
|
||||
self.assertEqual(profile1.age, 55)
|
||||
|
||||
def test_unique_true_enforces_max_num_one(self):
|
||||
|
@ -956,7 +960,8 @@ class ModelFormsetTest(TestCase):
|
|||
result = re.sub(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)?', '__DATETIME__', result)
|
||||
self.assertEqual(result,
|
||||
'<p><label for="id_membership_set-0-date_joined">Date joined:</label> <input type="text" name="membership_set-0-date_joined" value="__DATETIME__" id="id_membership_set-0-date_joined" /><input type="hidden" name="initial-membership_set-0-date_joined" value="__DATETIME__" id="initial-membership_set-0-id_membership_set-0-date_joined" /></p>\n'
|
||||
'<p><label for="id_membership_set-0-karma">Karma:</label> <input type="text" name="membership_set-0-karma" id="id_membership_set-0-karma" /><input type="hidden" name="membership_set-0-person" value="1" id="id_membership_set-0-person" /><input type="hidden" name="membership_set-0-id" id="id_membership_set-0-id" /></p>')
|
||||
'<p><label for="id_membership_set-0-karma">Karma:</label> <input type="text" name="membership_set-0-karma" id="id_membership_set-0-karma" /><input type="hidden" name="membership_set-0-person" value="%d" id="id_membership_set-0-person" /><input type="hidden" name="membership_set-0-id" id="id_membership_set-0-id" /></p>'
|
||||
% person.id)
|
||||
|
||||
# test for validation with callable defaults. Validations rely on hidden fields
|
||||
|
||||
|
|
|
@ -794,8 +794,8 @@ class AdminViewPermissionsTest(TestCase):
|
|||
self.client.get('/test_admin/admin/logout/')
|
||||
|
||||
# Test redirection when using row-level change permissions. Refs #11513.
|
||||
RowLevelChangePermissionModel.objects.create(name="odd id")
|
||||
RowLevelChangePermissionModel.objects.create(name="even id")
|
||||
RowLevelChangePermissionModel.objects.create(id=1, name="odd id")
|
||||
RowLevelChangePermissionModel.objects.create(id=2, name="even id")
|
||||
for login_dict in [self.super_login, self.changeuser_login, self.adduser_login, self.deleteuser_login]:
|
||||
self.client.post('/test_admin/admin/', login_dict)
|
||||
request = self.client.get('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/')
|
||||
|
@ -871,12 +871,13 @@ class AdminViewPermissionsTest(TestCase):
|
|||
})
|
||||
self.assertRedirects(post, '/test_admin/admin/admin_views/customarticle/')
|
||||
self.assertEqual(CustomArticle.objects.all().count(), 1)
|
||||
article_pk = CustomArticle.objects.all()[0].pk
|
||||
|
||||
# Test custom delete, change, and object history templates
|
||||
# Test custom change form template
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/1/')
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/%d/' % article_pk)
|
||||
self.assertTemplateUsed(request, 'custom_admin/change_form.html')
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/1/delete/')
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/%d/delete/' % article_pk)
|
||||
self.assertTemplateUsed(request, 'custom_admin/delete_confirmation.html')
|
||||
request = self.client.post('/test_admin/admin/admin_views/customarticle/', data={
|
||||
'index': 0,
|
||||
|
@ -884,7 +885,7 @@ class AdminViewPermissionsTest(TestCase):
|
|||
'_selected_action': ['1'],
|
||||
})
|
||||
self.assertTemplateUsed(request, 'custom_admin/delete_selected_confirmation.html')
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/1/history/')
|
||||
request = self.client.get('/test_admin/admin/admin_views/customarticle/%d/history/' % article_pk)
|
||||
self.assertTemplateUsed(request, 'custom_admin/object_history.html')
|
||||
|
||||
self.client.get('/test_admin/admin/logout/')
|
||||
|
@ -1478,27 +1479,27 @@ class AdminViewListEditable(TestCase):
|
|||
''' Ensure that non field errors are displayed for each of the
|
||||
forms in the changelist's formset. Refs #13126.
|
||||
'''
|
||||
FoodDelivery.objects.create(reference='123', driver='bill', restaurant='thai')
|
||||
FoodDelivery.objects.create(reference='456', driver='bill', restaurant='india')
|
||||
FoodDelivery.objects.create(reference='789', driver='bill', restaurant='pizza')
|
||||
fd1 = FoodDelivery.objects.create(reference='123', driver='bill', restaurant='thai')
|
||||
fd2 = FoodDelivery.objects.create(reference='456', driver='bill', restaurant='india')
|
||||
fd3 = FoodDelivery.objects.create(reference='789', driver='bill', restaurant='pizza')
|
||||
|
||||
data = {
|
||||
"form-TOTAL_FORMS": "3",
|
||||
"form-INITIAL_FORMS": "3",
|
||||
"form-MAX_NUM_FORMS": "0",
|
||||
|
||||
"form-0-id": "1",
|
||||
"form-0-id": str(fd1.id),
|
||||
"form-0-reference": "123",
|
||||
"form-0-driver": "bill",
|
||||
"form-0-restaurant": "thai",
|
||||
|
||||
# Same data as above: Forbidden because of unique_together!
|
||||
"form-1-id": "2",
|
||||
"form-1-id": str(fd2.id),
|
||||
"form-1-reference": "456",
|
||||
"form-1-driver": "bill",
|
||||
"form-1-restaurant": "thai",
|
||||
|
||||
"form-2-id": "3",
|
||||
"form-2-id": str(fd3.id),
|
||||
"form-2-reference": "789",
|
||||
"form-2-driver": "bill",
|
||||
"form-2-restaurant": "pizza",
|
||||
|
@ -1513,19 +1514,19 @@ class AdminViewListEditable(TestCase):
|
|||
"form-INITIAL_FORMS": "3",
|
||||
"form-MAX_NUM_FORMS": "0",
|
||||
|
||||
"form-0-id": "1",
|
||||
"form-0-id": str(fd1.id),
|
||||
"form-0-reference": "123",
|
||||
"form-0-driver": "bill",
|
||||
"form-0-restaurant": "thai",
|
||||
|
||||
# Same data as above: Forbidden because of unique_together!
|
||||
"form-1-id": "2",
|
||||
"form-1-id": str(fd2.id),
|
||||
"form-1-reference": "456",
|
||||
"form-1-driver": "bill",
|
||||
"form-1-restaurant": "thai",
|
||||
|
||||
# Same data also.
|
||||
"form-2-id": "3",
|
||||
"form-2-id": str(fd3.id),
|
||||
"form-2-reference": "789",
|
||||
"form-2-driver": "bill",
|
||||
"form-2-restaurant": "thai",
|
||||
|
@ -1685,28 +1686,28 @@ class AdminViewListEditable(TestCase):
|
|||
separately (not in the table), and only once.
|
||||
Refs #12475.
|
||||
"""
|
||||
Story.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...')
|
||||
Story.objects.create(title='Crouching Tiger, Hidden Python', content='The Python was sneaking into...')
|
||||
story1 = Story.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...')
|
||||
story2 = Story.objects.create(title='Crouching Tiger, Hidden Python', content='The Python was sneaking into...')
|
||||
response = self.client.get('/test_admin/admin/admin_views/story/')
|
||||
self.assertContains(response, 'id="id_form-0-id"', 1) # Only one hidden field, in a separate place than the table.
|
||||
self.assertContains(response, 'id="id_form-1-id"', 1)
|
||||
self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="2" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="1" id="id_form-1-id" />\n</div>')
|
||||
self.assertContains(response, '<td>1</td>', 1)
|
||||
self.assertContains(response, '<td>2</td>', 1)
|
||||
self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="%d" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="%d" id="id_form-1-id" />\n</div>' % (story2.id, story1.id))
|
||||
self.assertContains(response, '<td>%d</td>' % story1.id, 1)
|
||||
self.assertContains(response, '<td>%d</td>' % story2.id, 1)
|
||||
|
||||
def test_pk_hidden_fields_with_list_display_links(self):
|
||||
""" Similarly as test_pk_hidden_fields, but when the hidden pk fields are
|
||||
referenced in list_display_links.
|
||||
Refs #12475.
|
||||
"""
|
||||
OtherStory.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...')
|
||||
OtherStory.objects.create(title='Crouching Tiger, Hidden Python', content='The Python was sneaking into...')
|
||||
story1 = OtherStory.objects.create(title='The adventures of Guido', content='Once upon a time in Djangoland...')
|
||||
story2 = OtherStory.objects.create(title='Crouching Tiger, Hidden Python', content='The Python was sneaking into...')
|
||||
response = self.client.get('/test_admin/admin/admin_views/otherstory/')
|
||||
self.assertContains(response, 'id="id_form-0-id"', 1) # Only one hidden field, in a separate place than the table.
|
||||
self.assertContains(response, 'id="id_form-1-id"', 1)
|
||||
self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="2" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="1" id="id_form-1-id" />\n</div>')
|
||||
self.assertContains(response, '<th><a href="1/">1</a></th>', 1)
|
||||
self.assertContains(response, '<th><a href="2/">2</a></th>', 1)
|
||||
self.assertContains(response, '<div class="hiddenfields">\n<input type="hidden" name="form-0-id" value="%d" id="id_form-0-id" /><input type="hidden" name="form-1-id" value="%d" id="id_form-1-id" />\n</div>' % (story2.id, story1.id))
|
||||
self.assertContains(response, '<th><a href="%d/">%d</a></th>' % (story1.id, story1.id), 1)
|
||||
self.assertContains(response, '<th><a href="%d/">%d</a></th>' % (story2.id, story2.id), 1)
|
||||
|
||||
|
||||
class AdminSearchTest(TestCase):
|
||||
|
@ -1801,9 +1802,13 @@ class AdminInheritedInlinesTest(TestCase):
|
|||
self.assertEqual(BarAccount.objects.all()[0].username, bar_user)
|
||||
self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
|
||||
|
||||
persona_id = Persona.objects.all()[0].id
|
||||
foo_id = FooAccount.objects.all()[0].id
|
||||
bar_id = BarAccount.objects.all()[0].id
|
||||
|
||||
# test the edit case
|
||||
|
||||
response = self.client.get('/test_admin/admin/admin_views/persona/1/')
|
||||
response = self.client.get('/test_admin/admin/admin_views/persona/%d/' % persona_id)
|
||||
names = name_re.findall(response.content)
|
||||
# make sure we have no duplicate HTML names
|
||||
self.assertEqual(len(names), len(set(names)))
|
||||
|
@ -1816,18 +1821,18 @@ class AdminInheritedInlinesTest(TestCase):
|
|||
"accounts-MAX_NUM_FORMS": u"0",
|
||||
|
||||
"accounts-0-username": "%s-1" % foo_user,
|
||||
"accounts-0-account_ptr": "1",
|
||||
"accounts-0-persona": "1",
|
||||
"accounts-0-account_ptr": str(foo_id),
|
||||
"accounts-0-persona": str(persona_id),
|
||||
|
||||
"accounts-2-TOTAL_FORMS": u"2",
|
||||
"accounts-2-INITIAL_FORMS": u"1",
|
||||
"accounts-2-MAX_NUM_FORMS": u"0",
|
||||
|
||||
"accounts-2-0-username": "%s-1" % bar_user,
|
||||
"accounts-2-0-account_ptr": "2",
|
||||
"accounts-2-0-persona": "1",
|
||||
"accounts-2-0-account_ptr": str(bar_id),
|
||||
"accounts-2-0-persona": str(persona_id),
|
||||
}
|
||||
response = self.client.post('/test_admin/admin/admin_views/persona/1/', post_data)
|
||||
response = self.client.post('/test_admin/admin/admin_views/persona/%d/' % persona_id, post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Persona.objects.count(), 1)
|
||||
self.assertEqual(FooAccount.objects.count(), 1)
|
||||
|
@ -2155,10 +2160,10 @@ class AdminInlineFileUploadTest(TestCase):
|
|||
file1.write('a' * (2 ** 21))
|
||||
filename = file1.name
|
||||
file1.close()
|
||||
g = Gallery(name="Test Gallery")
|
||||
g.save()
|
||||
p = Picture(name="Test Picture", image=filename, gallery=g)
|
||||
p.save()
|
||||
self.gallery = Gallery(name="Test Gallery")
|
||||
self.gallery.save()
|
||||
self.picture = Picture(name="Test Picture", image=filename, gallery=self.gallery)
|
||||
self.picture.save()
|
||||
|
||||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
@ -2172,16 +2177,16 @@ class AdminInlineFileUploadTest(TestCase):
|
|||
"pictures-TOTAL_FORMS": u"2",
|
||||
"pictures-INITIAL_FORMS": u"1",
|
||||
"pictures-MAX_NUM_FORMS": u"0",
|
||||
"pictures-0-id": u"1",
|
||||
"pictures-0-gallery": u"1",
|
||||
"pictures-0-id": unicode(self.picture.id),
|
||||
"pictures-0-gallery": unicode(self.gallery.id),
|
||||
"pictures-0-name": "Test Picture",
|
||||
"pictures-0-image": "",
|
||||
"pictures-1-id": "",
|
||||
"pictures-1-gallery": "1",
|
||||
"pictures-1-gallery": str(self.gallery.id),
|
||||
"pictures-1-name": "Test Picture 2",
|
||||
"pictures-1-image": "",
|
||||
}
|
||||
response = self.client.post('/test_admin/%s/admin_views/gallery/1/' % self.urlbit, post_data)
|
||||
response = self.client.post('/test_admin/%s/admin_views/gallery/%d/' % (self.urlbit, self.gallery.id), post_data)
|
||||
self.assertTrue(response._container[0].find("Currently:") > -1)
|
||||
|
||||
|
||||
|
@ -2286,29 +2291,31 @@ class AdminInlineTests(TestCase):
|
|||
"A simple model can be saved as inlines"
|
||||
# First add a new inline
|
||||
self.post_data['widget_set-0-name'] = "Widget 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
collector_url = '/test_admin/admin/admin_views/collector/%d/' % self.collector.pk
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Widget.objects.count(), 1)
|
||||
self.assertEqual(Widget.objects.all()[0].name, "Widget 1")
|
||||
widget_id = Widget.objects.all()[0].id
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
response = self.client.get('/test_admin/admin/admin_views/collector/1/')
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="widget_set-0-id"')
|
||||
|
||||
# Now resave that inline
|
||||
self.post_data['widget_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['widget_set-0-id'] = "1"
|
||||
self.post_data['widget_set-0-id'] = str(widget_id)
|
||||
self.post_data['widget_set-0-name'] = "Widget 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Widget.objects.count(), 1)
|
||||
self.assertEqual(Widget.objects.all()[0].name, "Widget 1")
|
||||
|
||||
# Now modify that inline
|
||||
self.post_data['widget_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['widget_set-0-id'] = "1"
|
||||
self.post_data['widget_set-0-id'] = str(widget_id)
|
||||
self.post_data['widget_set-0-name'] = "Widget 1 Updated"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Widget.objects.count(), 1)
|
||||
self.assertEqual(Widget.objects.all()[0].name, "Widget 1 Updated")
|
||||
|
@ -2317,29 +2324,30 @@ class AdminInlineTests(TestCase):
|
|||
"A model with an explicit autofield primary key can be saved as inlines. Regression for #8093"
|
||||
# First add a new inline
|
||||
self.post_data['grommet_set-0-name'] = "Grommet 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
collector_url = '/test_admin/admin/admin_views/collector/%d/' % self.collector.pk
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Grommet.objects.count(), 1)
|
||||
self.assertEqual(Grommet.objects.all()[0].name, "Grommet 1")
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
response = self.client.get('/test_admin/admin/admin_views/collector/1/')
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="grommet_set-0-code"')
|
||||
|
||||
# Now resave that inline
|
||||
self.post_data['grommet_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['grommet_set-0-code'] = "1"
|
||||
self.post_data['grommet_set-0-code'] = str(Grommet.objects.all()[0].code)
|
||||
self.post_data['grommet_set-0-name'] = "Grommet 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Grommet.objects.count(), 1)
|
||||
self.assertEqual(Grommet.objects.all()[0].name, "Grommet 1")
|
||||
|
||||
# Now modify that inline
|
||||
self.post_data['grommet_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['grommet_set-0-code'] = "1"
|
||||
self.post_data['grommet_set-0-code'] = str(Grommet.objects.all()[0].code)
|
||||
self.post_data['grommet_set-0-name'] = "Grommet 1 Updated"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Grommet.objects.count(), 1)
|
||||
self.assertEqual(Grommet.objects.all()[0].name, "Grommet 1 Updated")
|
||||
|
@ -2349,20 +2357,21 @@ class AdminInlineTests(TestCase):
|
|||
# First add a new inline
|
||||
self.post_data['doohickey_set-0-code'] = "DH1"
|
||||
self.post_data['doohickey_set-0-name'] = "Doohickey 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
collector_url = '/test_admin/admin/admin_views/collector/%d/' % self.collector.pk
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(DooHickey.objects.count(), 1)
|
||||
self.assertEqual(DooHickey.objects.all()[0].name, "Doohickey 1")
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
response = self.client.get('/test_admin/admin/admin_views/collector/1/')
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="doohickey_set-0-code"')
|
||||
|
||||
# Now resave that inline
|
||||
self.post_data['doohickey_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['doohickey_set-0-code'] = "DH1"
|
||||
self.post_data['doohickey_set-0-name'] = "Doohickey 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(DooHickey.objects.count(), 1)
|
||||
self.assertEqual(DooHickey.objects.all()[0].name, "Doohickey 1")
|
||||
|
@ -2371,7 +2380,7 @@ class AdminInlineTests(TestCase):
|
|||
self.post_data['doohickey_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['doohickey_set-0-code'] = "DH1"
|
||||
self.post_data['doohickey_set-0-name'] = "Doohickey 1 Updated"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(DooHickey.objects.count(), 1)
|
||||
self.assertEqual(DooHickey.objects.all()[0].name, "Doohickey 1 Updated")
|
||||
|
@ -2412,29 +2421,31 @@ class AdminInlineTests(TestCase):
|
|||
"An inherited model can be saved as inlines. Regression for #11042"
|
||||
# First add a new inline
|
||||
self.post_data['fancydoodad_set-0-name'] = "Fancy Doodad 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
collector_url = '/test_admin/admin/admin_views/collector/%d/' % self.collector.pk
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(FancyDoodad.objects.count(), 1)
|
||||
self.assertEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1")
|
||||
doodad_pk = FancyDoodad.objects.all()[0].pk
|
||||
|
||||
# Check that the PK link exists on the rendered form
|
||||
response = self.client.get('/test_admin/admin/admin_views/collector/1/')
|
||||
response = self.client.get(collector_url)
|
||||
self.assertContains(response, 'name="fancydoodad_set-0-doodad_ptr"')
|
||||
|
||||
# Now resave that inline
|
||||
self.post_data['fancydoodad_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['fancydoodad_set-0-doodad_ptr'] = "1"
|
||||
self.post_data['fancydoodad_set-0-doodad_ptr'] = str(doodad_pk)
|
||||
self.post_data['fancydoodad_set-0-name'] = "Fancy Doodad 1"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(FancyDoodad.objects.count(), 1)
|
||||
self.assertEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1")
|
||||
|
||||
# Now modify that inline
|
||||
self.post_data['fancydoodad_set-INITIAL_FORMS'] = "1"
|
||||
self.post_data['fancydoodad_set-0-doodad_ptr'] = "1"
|
||||
self.post_data['fancydoodad_set-0-doodad_ptr'] = str(doodad_pk)
|
||||
self.post_data['fancydoodad_set-0-name'] = "Fancy Doodad 1 Updated"
|
||||
response = self.client.post('/test_admin/admin/admin_views/collector/1/', self.post_data)
|
||||
response = self.client.post(collector_url, self.post_data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(FancyDoodad.objects.count(), 1)
|
||||
self.assertEqual(FancyDoodad.objects.all()[0].name, "Fancy Doodad 1 Updated")
|
||||
|
@ -2952,4 +2963,3 @@ class DateHierarchyTests(TestCase):
|
|||
self.assert_non_localized_year(response, 2000)
|
||||
self.assert_non_localized_year(response, 2003)
|
||||
self.assert_non_localized_year(response, 2005)
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ class DeletionTests(TestCase):
|
|||
"""
|
||||
PoemFormSet = inlineformset_factory(Poet, Poem, can_delete=True)
|
||||
poet = Poet.objects.create(name='test')
|
||||
poet.poem_set.create(name='test poem')
|
||||
poem = poet.poem_set.create(name='test poem')
|
||||
data = {
|
||||
'poem_set-TOTAL_FORMS': u'1',
|
||||
'poem_set-INITIAL_FORMS': u'1',
|
||||
'poem_set-MAX_NUM_FORMS': u'0',
|
||||
'poem_set-0-id': u'1',
|
||||
'poem_set-0-poem': u'1',
|
||||
'poem_set-0-id': unicode(poem.id),
|
||||
'poem_set-0-poem': unicode(poem.id),
|
||||
'poem_set-0-name': u'x' * 1000,
|
||||
}
|
||||
formset = PoemFormSet(data, instance=poet)
|
||||
|
|
Loading…
Reference in New Issue