summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_widgets/tests.py
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2010-03-02 02:39:26 +0000
committerKaren Tracey <kmtracey@gmail.com>2010-03-02 02:39:26 +0000
commit08a698ed462b0e20a3a15b196152fee53e48ced9 (patch)
tree87f3157062b490bac10d669f5fa00db9e2da39c2 /tests/regressiontests/admin_widgets/tests.py
parent5f70a728767236a18b8effaa120e2218b7307c9b (diff)
[1.1.X] Fixed #11465: Ensure nonexistent pks enterd in an admin raw id field do not
cause a server error. Thanks for report and initial patch sacre@wp.pl. Backport of r12648 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12649 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_widgets/tests.py')
-rw-r--r--tests/regressiontests/admin_widgets/tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 85651542bb..64e12e3eaa 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -130,3 +130,27 @@ class AdminForeignKeyWidgetChangeList(DjangoTestCase):
class OldAdminForeignKeyWidgetChangeList(AdminForeignKeyWidgetChangeList):
urls = 'regressiontests.admin_widgets.urls2'
admin_root = '/deep/down/admin'
+
+class AdminForeignKeyRawIdWidget(DjangoTestCase):
+ fixtures = ["admin-widgets-users.xml"]
+ admin_root = '/widget_admin'
+
+ def setUp(self):
+ self.client.login(username="super", password="secret")
+
+ def tearDown(self):
+ self.client.logout()
+
+ def test_nonexistent_target_id(self):
+ band = models.Band.objects.create(name='Bogey Blues')
+ pk = band.pk
+ band.delete()
+ post_data = {
+ "band": u'%s' % pk,
+ }
+ # Try posting with a non-existent pk in a raw id field: this
+ # should result in an error message, not a server exception.
+ response = self.client.post('%s/admin_widgets/event/add/' % self.admin_root,
+ post_data)
+ self.assertContains(response,
+ 'Select a valid choice. That choice is not one of the available choices.')