Ticket #9663: save_as_inline_tests.diff

File save_as_inline_tests.diff, 3.0 KB (added by Andreas Pelme, 16 years ago)

Updated admin_views unit tests

  • tests/regressiontests/admin_views/tests.py

     
    8080            "article_set-0-content": u"<p>Middle content</p>",
    8181            "article_set-0-date_0": u"2008-03-18",
    8282            "article_set-0-date_1": u"11:54:58",
     83            'article_set-0-section': u'1',
     84
    8385            "article_set-1-id": u"2",
    8486            "article_set-1-title": u"Need a title.",
    8587            "article_set-1-content": u"<p>Oldest content</p>",
    8688            "article_set-1-date_0": u"2000-03-18",
    8789            "article_set-1-date_1": u"11:54:58",
     90            'article_set-1-section': u'1',
     91
    8892            "article_set-2-id": u"3",
    8993            "article_set-2-title": u"Need a title.",
    9094            "article_set-2-content": u"<p>Newest content</p>",
    9195            "article_set-2-date_0": u"2009-03-18",
    9296            "article_set-2-date_1": u"11:54:58",
     97            'article_set-2-section': u'1',
     98
    9399            "article_set-3-id": u"",
    94100            "article_set-3-title": u"",
    95101            "article_set-3-content": u"",
    96102            "article_set-3-date_0": u"",
    97103            "article_set-3-date_1": u"",
     104            'article_set-3-section': u'1',
     105
    98106            "article_set-4-id": u"",
    99107            "article_set-4-title": u"",
    100108            "article_set-4-content": u"",
    101109            "article_set-4-date_0": u"",
    102110            "article_set-4-date_1": u"",
     111            'article_set-4-section': u'1',
     112
    103113            "article_set-5-id": u"",
    104114            "article_set-5-title": u"",
    105115            "article_set-5-content": u"",
    106116            "article_set-5-date_0": u"",
    107117            "article_set-5-date_1": u"",
     118            'article_set-5-section': u'1',
    108119        }
    109120        response = self.client.post('/test_admin/admin/admin_views/section/1/', post_data)
    110121        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
    111122
     123        # test save_as
     124        post_data.update({
     125            '_saveasnew': u'Save+as+new',
     126        })
     127
     128        response = self.client.post('/test_admin/admin/admin_views/section/1/', post_data)
     129        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
     130
    112131    def testChangeListSortingCallable(self):
    113132        """
    114133        Ensure we can sort on a list_display field that is a callable
  • tests/regressiontests/admin_views/models.py

     
    9191
    9292admin.site.register(Article, ArticleAdmin)
    9393admin.site.register(CustomArticle, CustomArticleAdmin)
    94 admin.site.register(Section, inlines=[ArticleInline])
     94admin.site.register(Section, save_as=True, inlines=[ArticleInline])
    9595admin.site.register(ModelWithStringPrimaryKey)
    9696admin.site.register(Color)
    9797admin.site.register(Thing, ThingAdmin)
Back to Top