1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #23934 -- Fixed regression in admin views obj parameter.

This commit is contained in:
Kamil Braun
2014-11-27 19:34:14 +01:00
committed by Tim Graham
parent 1da1fe8e16
commit 0623f4dea4
5 changed files with 92 additions and 7 deletions

View File

@@ -5207,3 +5207,51 @@ class TestEtagWithAdminView(TestCase):
response = self.client.get('/test_admin/admin/')
self.assertEqual(response.status_code, 302)
self.assertTrue(response.has_header('ETag'))
@override_settings(
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
ROOT_URLCONF="admin_views.urls",
)
class GetFormsetsWithInlinesArgumentTest(TestCase):
"""
#23934 - When adding a new model instance in the admin, the 'obj' argument
of get_formsets_with_inlines() should be None. When changing, it should be
equal to the existing model instance.
The GetFormsetsArgumentCheckingAdmin ModelAdmin throws an exception
if obj is not None during add_view or obj is None during change_view.
"""
fixtures = ['admin-views-users.xml']
def setUp(self):
self.client.login(username='super', password='secret')
def test_explicitly_provided_pk(self):
post_data = {'name': '1'}
try:
response = self.client.post('/test_admin/admin/admin_views/explicitlyprovidedpk/add/', post_data)
except Exception as e:
self.fail(e)
self.assertEqual(response.status_code, 302)
post_data = {'name': '2'}
try:
response = self.client.post('/test_admin/admin/admin_views/explicitlyprovidedpk/1/', post_data)
except Exception as e:
self.fail(e)
self.assertEqual(response.status_code, 302)
def test_implicitly_generated_pk(self):
post_data = {'name': '1'}
try:
response = self.client.post('/test_admin/admin/admin_views/implicitlygeneratedpk/add/', post_data)
except Exception as e:
self.fail(e)
self.assertEqual(response.status_code, 302)
post_data = {'name': '2'}
try:
response = self.client.post('/test_admin/admin/admin_views/implicitlygeneratedpk/1/', post_data)
except Exception as e:
self.fail(e)
self.assertEqual(response.status_code, 302)