Ticket #10992: 10992_tests.diff
File 10992_tests.diff, 3.2 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/admin_views/tests.py
16 16 from models import (Article, BarAccount, CustomArticle, EmptyModel, 17 17 ExternalSubscriber, FooAccount, Gallery, 18 18 ModelWithStringPrimaryKey, Person, Persona, Picture, 19 Podcast, Section, Subscriber, Vodcast, Language )19 Podcast, Section, Subscriber, Vodcast, Language, Master, Detail) 20 20 21 21 try: 22 22 set … … 908 908 # confirm the search returned 1 object 909 909 self.assertContains(response, "\n1 recommendation\n") 910 910 911 class SaveCustomPKInlines(TestCase): 912 fixtures = ['admin-views-users'] 913 914 def setUp(self): 915 self.client.login(username='super', password='secret') 916 917 master = Master(codice="djangocon") 918 master.save() 919 detail = Detail(codice="prague", fk=master) 920 detail.save() 921 922 def tearDown(self): 923 self.client.logout() 924 925 def test_saving_existing_inline(self): 926 data = { 927 "detail_set-0-fk": "djangocon", 928 "codice": "djangocon", 929 "detail_set-2-codice": "", 930 "detail_set-INITIAL_FORMS": "1", 931 "detail_set-1-fk": "djangocon", 932 "detail_set-2-fk": "djangocon", 933 "detail_set-3-fk": "djangocon", 934 "detail_set-0-codice": "prague", 935 "detail_set-TOTAL_FORMS": "4", 936 "detail_set-1-codice": "", 937 "detail_set-3-codice": "", 938 "_save": "Save" 939 } 940 941 response = self.client.post('/test_admin/admin/admin_views/master/djangocon/', 942 data, follow=True) 943 944 self.failUnlessEqual(response.status_code, 200) 945 911 946 class AdminInheritedInlinesTest(TestCase): 912 947 fixtures = ['admin-views-users.xml',] 913 948 -
tests/regressiontests/admin_views/models.py
356 356 class RecommendationAdmin(admin.ModelAdmin): 357 357 search_fields = ('titletranslation__text', 'recommender__titletranslation__text',) 358 358 359 class Master(models.Model): 360 codice = models.CharField(primary_key=True, max_length=30) 359 361 362 class Detail(models.Model): 363 codice = models.CharField(primary_key=True, max_length=30) 364 fk = models.ForeignKey(Master) 365 366 class DetailInline(admin.TabularInline): 367 model = Detail 368 369 class MasterAdmin(admin.ModelAdmin): 370 inlines = [DetailInline,] 371 360 372 admin.site.register(Article, ArticleAdmin) 361 373 admin.site.register(CustomArticle, CustomArticleAdmin) 362 374 admin.site.register(Section, save_as=True, inlines=[ArticleInline]) … … 378 390 admin.site.register(Language, LanguageAdmin) 379 391 admin.site.register(Recommendation, RecommendationAdmin) 380 392 admin.site.register(Recommender) 393 admin.site.register(Master, MasterAdmin) 381 394 382 395 # We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2. 383 396 # That way we cover all four cases: