Ticket #9863: test_9863.diff

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

Stand-alone django test case exhibiting the problem

  • tests/regressiontests/admin_views_9863/fixtures/admin-views-users.xml

     
     1<?xml version="1.0" encoding="utf-8"?>
     2<django-objects version="1.0">
     3    <object pk="100" model="auth.user">
     4        <field type="CharField" name="username">super</field>
     5        <field type="CharField" name="first_name">Super</field>
     6        <field type="CharField" name="last_name">User</field>
     7        <field type="CharField" name="email">super@example.com</field>
     8        <field type="CharField" name="password">sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158</field>
     9        <field type="BooleanField" name="is_staff">True</field>
     10        <field type="BooleanField" name="is_active">True</field>
     11        <field type="BooleanField" name="is_superuser">True</field>
     12        <field type="DateTimeField" name="last_login">2007-05-30 13:20:10</field>
     13        <field type="DateTimeField" name="date_joined">2007-05-30 13:20:10</field>
     14        <field to="auth.group" name="groups" rel="ManyToManyRel"></field>
     15        <field to="auth.permission" name="user_permissions" rel="ManyToManyRel"></field>
     16    </object>
     17</django-objects>
     18 No newline at end of file
  • tests/regressiontests/admin_views_9863/models.py

     
     1# -*- coding: utf-8 -*-
     2from django.db import models
     3from django.contrib import admin
     4
     5class Parent(models.Model):   
     6    name = models.CharField(max_length = 128, db_index = True)   
     7
     8class Child(models.Model):   
     9    parent = models.ForeignKey(Parent, related_name = 'child_set', editable = False)
     10    name = models.CharField(max_length = 30, blank = True)   
     11
     12class ChildInline(admin.StackedInline):
     13    model = Child
     14    extra = 10
     15
     16class ParentAdmin(admin.ModelAdmin):
     17    model = Parent
     18    inlines = [
     19       ChildInline,     
     20    ]
     21
     22admin.site.register(Parent, ParentAdmin)
  • tests/regressiontests/admin_views_9863/tests.py

     
     1# coding: utf-8
     2
     3from django.test import TestCase
     4
     5class TestTicket9863(TestCase):
     6    fixtures = ['admin-views-users.xml', ]
     7   
     8    def setUp(self):
     9        result = self.client.login(username='super', password='secret')
     10        self.failUnlessEqual(result, True)
     11
     12    def tearDown(self):
     13        self.client.logout()
     14
     15    def test(self):
     16        """
     17        InlineModelAdmin broken?
     18        """
     19        response = self.client.get('/test_admin/admin/admin_views_9863/parent/add/')
     20        print response
     21        self.failUnlessEqual(response.status_code, 200)
  • tests/regressiontests/admin_views_9863/urls.py

     
     1from django.conf.urls.defaults import *
     2from django.contrib import admin
     3
     4urlpatterns = patterns('',
     5    (r'^admin/', include(admin.site.urls)),
     6)
Back to Top