Ticket #17333: 17333-wip-regression-tests.diff
File 17333-wip-regression-tests.diff, 3.7 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/admin_views/admin.py
diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py
a b 24 24 CoverLetter, Story, OtherStory, Book, Promo, ChapterXtra1, Pizza, Topping, 25 25 Album, Question, Answer, ComplexSortedPerson, PrePopulatedPostLargeSlug, 26 26 AdminOrderedField, AdminOrderedModelMethod, AdminOrderedAdminMethod, 27 AdminOrderedCallable )27 AdminOrderedCallable, Report) 28 28 29 29 30 30 def callable_year(dt_value): … … 499 499 ordering = ('order',) 500 500 list_display = ('stuff', admin_ordered_callable) 501 501 502 class ReportAdmin(admin.ModelAdmin): 503 def has_add_permission(self, request): 504 return False 502 505 503 506 site = admin.AdminSite(name="admin") 504 507 site.register(Article, ArticleAdmin) … … 543 546 site.register(CoverLetter, CoverLetterAdmin) 544 547 site.register(Story, StoryAdmin) 545 548 site.register(OtherStory, OtherStoryAdmin) 549 site.register(Report, ReportAdmin) 546 550 547 551 # We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2. 548 552 # That way we cover all four cases: -
tests/regressiontests/admin_views/models.py
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
a b 566 566 class AdminOrderedCallable(models.Model): 567 567 order = models.IntegerField() 568 568 stuff = models.CharField(max_length=200) 569 570 class Report(models.Model): 571 title = models.CharField(max_length=100) 572 573 def __unicode__(self): 574 return self.title -
tests/regressiontests/admin_views/tests.py
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
a b 38 38 Book, Promo, WorkHour, Employee, Question, Answer, Inquisition, Actor, 39 39 FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story, 40 40 OtherStory, ComplexSortedPerson, Parent, Child, AdminOrderedField, 41 AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable) 41 AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable, 42 Report) 42 43 43 44 44 45 ERROR_MESSAGE = "Please enter the correct username and password \ … … 1090 1091 self.assertContains(response, 'id="login-form"') 1091 1092 1092 1093 1094 class AdminViewsNoPermissionsTest(TestCase): 1095 """Regression test for #17333""" 1096 1097 urls = "regressiontests.admin_views.urls" 1098 fixtures = ['admin-views-users.xml'] 1099 1100 def setUp(self): 1101 opts = Report._meta 1102 1103 # Programmatically remove add and change perms from on the Report model 1104 # that syncdb should have created for us 1105 #get_perm(Report, opts.get_add_permission()).delete() 1106 #get_perm(Report, opts.get_change_permission()).delete() 1107 1108 # User who can change Reports 1109 change_user = User.objects.get(username='changeuser') 1110 change_user.user_permissions.add(get_perm(Report, 1111 opts.get_change_permission())) 1112 1113 # login POST dict 1114 self.changeuser_login = { 1115 REDIRECT_FIELD_NAME: '/test_admin/admin/', 1116 LOGIN_FORM_KEY: 1, 1117 'username': 'changeuser', 1118 'password': 'secret', 1119 } 1120 1121 def test_no_add_perms(self): 1122 self.client.get('/test_admin/admin/') 1123 self.client.post('/test_admin/admin/', self.changeuser_login) 1124 r = self.client.get('/test_admin/admin/') 1125 self.assertEqual(r.status_code, 200) 1126 self.client.get('/test_admin/admin/logout/') 1127 1093 1128 class AdminViewDeletedObjectsTest(TestCase): 1094 1129 urls = "regressiontests.admin_views.urls" 1095 1130 fixtures = ['admin-views-users.xml', 'deleted-objects.xml']