Code

Ticket #9863: test_9863.diff

File test_9863.diff, 3.6 KB (added by keithb, 5 years ago)

Stand-alone django test case exhibiting the problem

Line 
1Index: tests/regressiontests/admin_views_9863/__init__.py
2===================================================================
3Index: tests/regressiontests/admin_views_9863/fixtures/admin-views-users.xml
4===================================================================
5--- tests/regressiontests/admin_views_9863/fixtures/admin-views-users.xml       (revision 0)
6+++ tests/regressiontests/admin_views_9863/fixtures/admin-views-users.xml       (revision 0)
7@@ -0,0 +1,17 @@
8+<?xml version="1.0" encoding="utf-8"?>
9+<django-objects version="1.0">
10+    <object pk="100" model="auth.user">
11+        <field type="CharField" name="username">super</field>
12+        <field type="CharField" name="first_name">Super</field>
13+        <field type="CharField" name="last_name">User</field>
14+        <field type="CharField" name="email">super@example.com</field>
15+        <field type="CharField" name="password">sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158</field>
16+        <field type="BooleanField" name="is_staff">True</field>
17+        <field type="BooleanField" name="is_active">True</field>
18+        <field type="BooleanField" name="is_superuser">True</field>
19+        <field type="DateTimeField" name="last_login">2007-05-30 13:20:10</field>
20+        <field type="DateTimeField" name="date_joined">2007-05-30 13:20:10</field>
21+        <field to="auth.group" name="groups" rel="ManyToManyRel"></field>
22+        <field to="auth.permission" name="user_permissions" rel="ManyToManyRel"></field>
23+    </object>
24+</django-objects>
25\ No newline at end of file
26Index: tests/regressiontests/admin_views_9863/models.py
27===================================================================
28--- tests/regressiontests/admin_views_9863/models.py    (revision 0)
29+++ tests/regressiontests/admin_views_9863/models.py    (revision 0)
30@@ -0,0 +1,22 @@
31+# -*- coding: utf-8 -*-
32+from django.db import models
33+from django.contrib import admin
34+
35+class Parent(models.Model):   
36+    name = models.CharField(max_length = 128, db_index = True)   
37+
38+class Child(models.Model):   
39+    parent = models.ForeignKey(Parent, related_name = 'child_set', editable = False)
40+    name = models.CharField(max_length = 30, blank = True)   
41+
42+class ChildInline(admin.StackedInline):
43+    model = Child
44+    extra = 10
45+
46+class ParentAdmin(admin.ModelAdmin):
47+    model = Parent
48+    inlines = [
49+       ChildInline,     
50+    ]
51+
52+admin.site.register(Parent, ParentAdmin)
53Index: tests/regressiontests/admin_views_9863/tests.py
54===================================================================
55--- tests/regressiontests/admin_views_9863/tests.py     (revision 0)
56+++ tests/regressiontests/admin_views_9863/tests.py     (revision 0)
57@@ -0,0 +1,21 @@
58+# coding: utf-8
59+
60+from django.test import TestCase
61+
62+class TestTicket9863(TestCase):
63+    fixtures = ['admin-views-users.xml', ]
64+   
65+    def setUp(self):
66+        result = self.client.login(username='super', password='secret')
67+        self.failUnlessEqual(result, True)
68+
69+    def tearDown(self):
70+        self.client.logout()
71+
72+    def test(self):
73+        """
74+        InlineModelAdmin broken?
75+        """
76+        response = self.client.get('/test_admin/admin/admin_views_9863/parent/add/')
77+        print response
78+        self.failUnlessEqual(response.status_code, 200)
79Index: tests/regressiontests/admin_views_9863/urls.py
80===================================================================
81--- tests/regressiontests/admin_views_9863/urls.py      (revision 0)
82+++ tests/regressiontests/admin_views_9863/urls.py      (revision 0)
83@@ -0,0 +1,6 @@
84+from django.conf.urls.defaults import *
85+from django.contrib import admin
86+
87+urlpatterns = patterns('',
88+    (r'^admin/', include(admin.site.urls)),
89+)