Ticket #26175: 26175.diff
File 26175.diff, 51.1 KB (added by , 9 years ago) |
---|
-
tests/admin_views/tests.py
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 55ff3c5..7fb5556 100644
a b class AdminFieldExtractionMixin(object): 104 104 return field 105 105 106 106 107 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 108 ROOT_URLCONF="admin_views.urls", 109 USE_I18N=True, USE_L10N=False, LANGUAGE_CODE='en') 107 @override_settings(ROOT_URLCONF='admin_views.urls', USE_I18N=True, USE_L10N=False, LANGUAGE_CODE='en') 110 108 class AdminViewBasicTestCase(TestCase): 111 109 112 110 @classmethod 113 111 def setUpTestData(cls): 114 cls.superuser = User.objects.create( 115 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 116 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 117 first_name='Super', last_name='User', email='super@example.com', 118 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 119 ) 112 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 120 113 cls.s1 = Section.objects.create(name='Test section') 121 114 cls.a1 = Article.objects.create( 122 115 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminCustomTemplateTests(AdminViewBasicTestCase): 995 988 self.assertTemplateUsed(response, 'custom_filter_template.html') 996 989 997 990 998 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 999 ROOT_URLCONF="admin_views.urls") 991 @override_settings(ROOT_URLCONF='admin_views.urls') 1000 992 class AdminViewFormUrlTest(TestCase): 1001 993 current_app = "admin3" 1002 994 1003 995 @classmethod 1004 996 def setUpTestData(cls): 1005 cls.superuser = User.objects.create( 1006 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1007 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 1008 first_name='Super', last_name='User', email='super@example.com', 1009 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1010 ) 997 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 1011 998 cls.s1 = Section.objects.create(name='Test section') 1012 999 cls.a1 = Article.objects.create( 1013 1000 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminViewFormUrlTest(TestCase): 1050 1037 self.assertContains(response, 'value="overridden_value"') 1051 1038 1052 1039 1053 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 1054 ROOT_URLCONF="admin_views.urls") 1040 @override_settings(ROOT_URLCONF='admin_views.urls') 1055 1041 class AdminJavaScriptTest(TestCase): 1056 1042 1057 1043 @classmethod 1058 1044 def setUpTestData(cls): 1059 cls.superuser = User.objects.create( 1060 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1061 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 1062 first_name='Super', last_name='User', email='super@example.com', 1063 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1064 ) 1045 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 1065 1046 1066 1047 def setUp(self): 1067 1048 self.client.force_login(self.superuser) … … class AdminJavaScriptTest(TestCase): 1098 1079 self.assertNotContains(response, 'inlines.min.js') 1099 1080 1100 1081 1101 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 1102 ROOT_URLCONF="admin_views.urls") 1082 @override_settings(ROOT_URLCONF='admin_views.urls') 1103 1083 class SaveAsTests(TestCase): 1104 1084 1105 1085 @classmethod 1106 1086 def setUpTestData(cls): 1107 cls.superuser = User.objects.create( 1108 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1109 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 1110 first_name='Super', last_name='User', email='super@example.com', 1111 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1112 ) 1087 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 1113 1088 cls.per1 = Person.objects.create(name='John Mauchly', gender=1, alive=True) 1114 1089 1115 1090 def setUp(self): … … class SaveAsTests(TestCase): 1177 1152 self.assertTrue(response.context['show_save_as_new']) 1178 1153 1179 1154 1180 @override_settings(ROOT_URLCONF= "admin_views.urls")1155 @override_settings(ROOT_URLCONF='admin_views.urls') 1181 1156 class CustomModelAdminTest(AdminViewBasicTestCase): 1182 1157 1183 1158 def test_custom_admin_site_login_form(self): … … def get_perm(Model, perm): 1264 1239 return Permission.objects.get(content_type=ct, codename=perm) 1265 1240 1266 1241 1267 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 1268 ROOT_URLCONF="admin_views.urls") 1242 @override_settings(ROOT_URLCONF='admin_views.urls') 1269 1243 class AdminViewPermissionsTest(TestCase): 1270 1244 """Tests for Admin Views Permissions.""" 1271 1245 1272 1246 @classmethod 1273 1247 def setUpTestData(cls): 1274 cls.superuser = User.objects.create( 1275 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1276 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 1277 first_name='Super', last_name='User', email='super@example.com', 1278 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1279 ) 1280 cls.adduser = User.objects.create( 1281 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1282 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='adduser', 1283 first_name='Add', last_name='User', email='auser@example.com', 1284 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1285 ) 1286 cls.changeuser = User.objects.create( 1287 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1288 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='changeuser', 1289 first_name='Change', last_name='User', email='cuser@example.com', 1290 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1291 ) 1292 cls.deleteuser = User.objects.create( 1293 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1294 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='deleteuser', 1295 first_name='Delete', last_name='User', email='duser@example.com', 1296 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1297 ) 1298 cls.joepublicuser = User.objects.create( 1299 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1300 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='joepublic', 1301 first_name='Joe', last_name='Public', email='joepublic@example.com', 1302 is_staff=False, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1303 ) 1304 cls.nostaffuser = User.objects.create( 1305 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 1306 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='nostaff', 1307 first_name='No', last_name='Staff', email='nostaff@example.com', 1308 is_staff=False, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 1309 ) 1248 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 1249 cls.adduser = User.objects.create_user(username='adduser', password='secret', is_staff=True) 1250 cls.changeuser = User.objects.create_user(username='changeuser', password='secret', is_staff=True) 1251 cls.deleteuser = User.objects.create_user(username='deleteuser', password='secret', is_staff=True) 1252 cls.joepublicuser = User.objects.create_user(username='joepublic', password='secret') 1253 cls.nostaffuser = User.objects.create_user(username='nostaff', password='secret') 1310 1254 cls.s1 = Section.objects.create(name='Test section') 1311 1255 cls.a1 = Article.objects.create( 1312 1256 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1, … … class AdminViewPermissionsTest(TestCase): 1542 1486 self.assertNotContains(response, hint_template.format(''), status_code=200) 1543 1487 1544 1488 # Non-staff user should be shown the hint 1545 self.client. login(**self.nostaff_login)1489 self.client.force_login(self.nostaffuser) 1546 1490 response = self.client.get(self.index_url, follow=True) 1547 1491 self.assertContains(response, 'login-form') 1548 1492 self.assertContains(response, hint_template.format(self.nostaffuser.username), status_code=200) … … class AdminViewPermissionsTest(TestCase): 1987 1931 Post-save message shouldn't contain a link to the change form if the 1988 1932 user doen't have the change permission. 1989 1933 """ 1990 login = self.client.post(reverse('admin:login'), self.adduser_login) 1991 self.assertRedirects(login, self.index_url) 1934 self.client.force_login(self.adduser) 1992 1935 # Emulate Article creation for user with add-only permission. 1993 1936 post_data = { 1994 1937 "title": "Fun & games", … … class AdminViewPermissionsTest(TestCase): 2005 1948 ) 2006 1949 2007 1950 2008 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2009 ROOT_URLCONF="admin_views.urls") 1951 @override_settings(ROOT_URLCONF='admin_views.urls') 2010 1952 class AdminViewsNoUrlTest(TestCase): 2011 1953 """Regression test for #17333""" 2012 1954 2013 1955 @classmethod 2014 1956 def setUpTestData(cls): 2015 cls.changeuser = User.objects.create(2016 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158',2017 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='changeuser',2018 first_name='Change', last_name='User', email='cuser@example.com',2019 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10)2020 )2021 2022 opts = Report._meta2023 1957 # User who can change Reports 2024 cls.changeuser.user_permissions.add(get_perm(Report, get_permission_codename('change', opts))) 1958 cls.changeuser = User.objects.create_user(username='changeuser', password='secret', is_staff=True) 1959 cls.changeuser.user_permissions.add(get_perm(Report, get_permission_codename('change', Report._meta))) 2025 1960 2026 1961 def test_no_standard_modeladmin_urls(self): 2027 1962 """Admin index views don't break when user's ModelAdmin removes standard urls""" … … class AdminViewsNoUrlTest(TestCase): 2033 1968 2034 1969 2035 1970 @skipUnlessDBFeature('can_defer_constraint_checks') 2036 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2037 ROOT_URLCONF="admin_views.urls") 1971 @override_settings(ROOT_URLCONF='admin_views.urls') 2038 1972 class AdminViewDeletedObjectsTest(TestCase): 2039 1973 2040 1974 @classmethod 2041 1975 def setUpTestData(cls): 2042 cls.superuser = User.objects.create( 2043 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2044 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2045 first_name='Super', last_name='User', email='super@example.com', 2046 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2047 ) 2048 cls.deleteuser = User.objects.create( 2049 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2050 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='deleteuser', 2051 first_name='Delete', last_name='User', email='duser@example.com', 2052 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2053 ) 1976 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 1977 cls.deleteuser = User.objects.create_user(username='deleteuser', password='secret', is_staff=True) 2054 1978 cls.s1 = Section.objects.create(name='Test section') 2055 1979 cls.a1 = Article.objects.create( 2056 1980 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminViewDeletedObjectsTest(TestCase): 2115 2039 def test_perms_needed(self): 2116 2040 self.client.logout() 2117 2041 delete_user = User.objects.get(username='deleteuser') 2118 delete_user.user_permissions.add(get_perm(Plot, 2119 get_permission_codename('delete', Plot._meta))) 2120 2121 self.assertTrue(self.client.login(username='deleteuser', 2122 password='secret')) 2042 delete_user.user_permissions.add(get_perm(Plot, get_permission_codename('delete', Plot._meta))) 2123 2043 2044 self.client.login(self.deleteuser) 2124 2045 response = self.client.get(reverse('admin:admin_views_plot_delete', args=(self.pl1.pk,))) 2125 2046 self.assertContains(response, "your account doesn't have permission to delete the following types of objects") 2126 2047 self.assertContains(response, "<li>plot details</li>") … … class AdminViewDeletedObjectsTest(TestCase): 2219 2140 self.assertContains(response, should_contain) 2220 2141 2221 2142 2222 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2223 ROOT_URLCONF="admin_views.urls") 2143 @override_settings(ROOT_URLCONF='admin_views.urls') 2224 2144 class TestGenericRelations(TestCase): 2225 2145 2226 2146 @classmethod 2227 2147 def setUpTestData(cls): 2228 cls.superuser = User.objects.create( 2229 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2230 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2231 first_name='Super', last_name='User', email='super@example.com', 2232 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2233 ) 2148 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 2234 2149 cls.v1 = Villain.objects.create(name='Adam') 2235 2150 cls.pl3 = Plot.objects.create(name='Corn Conspiracy', team_leader=cls.v1, contact=cls.v1) 2236 2151 … … class TestGenericRelations(TestCase): 2243 2158 self.assertContains(response, "%s</td>" % self.pl3) 2244 2159 2245 2160 2246 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2247 ROOT_URLCONF="admin_views.urls") 2161 @override_settings(ROOT_URLCONF='admin_views.urls') 2248 2162 class AdminViewStringPrimaryKeyTest(TestCase): 2249 2163 2250 2164 @classmethod 2251 2165 def setUpTestData(cls): 2252 cls.superuser = User.objects.create( 2253 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2254 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2255 first_name='Super', last_name='User', email='super@example.com', 2256 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2257 ) 2166 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 2258 2167 cls.s1 = Section.objects.create(name='Test section') 2259 2168 cls.a1 = Article.objects.create( 2260 2169 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminViewStringPrimaryKeyTest(TestCase): 2400 2309 self.assertIn('/123_2Fhistory/', response['location']) # PK is quoted 2401 2310 2402 2311 2403 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2404 ROOT_URLCONF="admin_views.urls") 2312 @override_settings(ROOT_URLCONF='admin_views.urls') 2405 2313 class SecureViewTests(TestCase): 2406 2314 """ 2407 2315 Test behavior of a view protected by the staff_member_required decorator. … … class SecureViewTests(TestCase): 2428 2336 self.assertRedirects(response, '%s?myfield=%s' % (reverse('admin:login'), secure_url)) 2429 2337 2430 2338 2431 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2432 ROOT_URLCONF="admin_views.urls") 2339 @override_settings(ROOT_URLCONF='admin_views.urls') 2433 2340 class AdminViewUnicodeTest(TestCase): 2434 2341 2435 2342 @classmethod 2436 2343 def setUpTestData(cls): 2437 cls.superuser = User.objects.create( 2438 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2439 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2440 first_name='Super', last_name='User', email='super@example.com', 2441 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2442 ) 2344 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 2443 2345 cls.b1 = Book.objects.create(name='Lærdommer') 2444 2346 cls.p1 = Promo.objects.create(name='<Promo for Lærdommer>', book=cls.b1) 2445 2347 cls.chap1 = Chapter.objects.create( … … class AdminViewUnicodeTest(TestCase): 2504 2406 self.assertRedirects(response, reverse('admin:admin_views_book_changelist')) 2505 2407 2506 2408 2507 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2508 ROOT_URLCONF="admin_views.urls") 2409 @override_settings(ROOT_URLCONF='admin_views.urls') 2509 2410 class AdminViewListEditable(TestCase): 2510 2411 2511 2412 @classmethod 2512 2413 def setUpTestData(cls): 2513 cls.superuser = User.objects.create( 2514 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2515 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2516 first_name='Super', last_name='User', email='super@example.com', 2517 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2518 ) 2414 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 2519 2415 cls.s1 = Section.objects.create(name='Test section') 2520 2416 cls.a1 = Article.objects.create( 2521 2417 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminViewListEditable(TestCase): 2937 2833 self.assertContains(response, '<th class="field-id"><a href="%s">%d</a></th>' % (link2, story2.id), 1) 2938 2834 2939 2835 2940 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 2941 ROOT_URLCONF="admin_views.urls") 2836 @override_settings(ROOT_URLCONF='admin_views.urls') 2942 2837 class AdminSearchTest(TestCase): 2943 2838 2944 2839 @classmethod 2945 2840 def setUpTestData(cls): 2946 cls.superuser = User.objects.create( 2947 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2948 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 2949 first_name='Super', last_name='User', email='super@example.com', 2950 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2951 ) 2952 cls.joepublicuser = User.objects.create( 2953 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 2954 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='joepublic', 2955 first_name='Joe', last_name='Public', email='joepublic@example.com', 2956 is_staff=False, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 2957 ) 2841 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 2842 cls.joepublicuser = User.objects.create_user(username='joepublic', password='secret') 2958 2843 cls.s1 = Section.objects.create(name='Test section') 2959 2844 cls.a1 = Article.objects.create( 2960 2845 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class AdminSearchTest(TestCase): 3061 2946 self.assertTrue(response.context['cl'].show_admin_actions) 3062 2947 3063 2948 3064 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3065 ROOT_URLCONF="admin_views.urls") 2949 @override_settings(ROOT_URLCONF='admin_views.urls') 3066 2950 class AdminInheritedInlinesTest(TestCase): 3067 2951 3068 2952 @classmethod 3069 2953 def setUpTestData(cls): 3070 cls.superuser = User.objects.create( 3071 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3072 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3073 first_name='Super', last_name='User', email='super@example.com', 3074 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3075 ) 2954 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3076 2955 3077 2956 def setUp(self): 3078 2957 self.client.force_login(self.superuser) … … class AdminInheritedInlinesTest(TestCase): 3153 3032 self.assertEqual(Persona.objects.all()[0].accounts.count(), 2) 3154 3033 3155 3034 3156 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3157 ROOT_URLCONF="admin_views.urls") 3035 @override_settings(ROOT_URLCONF='admin_views.urls') 3158 3036 class AdminActionsTest(TestCase): 3159 3037 3160 3038 @classmethod 3161 3039 def setUpTestData(cls): 3162 cls.superuser = User.objects.create( 3163 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3164 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3165 first_name='Super', last_name='User', email='super@example.com', 3166 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3167 ) 3040 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3168 3041 cls.s1 = ExternalSubscriber.objects.create(name='John Doe', email='john@example.org') 3169 3042 cls.s2 = Subscriber.objects.create(name='Max Mustermann', email='max@example.org') 3170 3043 … … action)</option> 3460 3333 ) 3461 3334 3462 3335 3463 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3464 ROOT_URLCONF="admin_views.urls") 3336 @override_settings(ROOT_URLCONF='admin_views.urls') 3465 3337 class TestCustomChangeList(TestCase): 3466 3338 3467 3339 @classmethod 3468 3340 def setUpTestData(cls): 3469 cls.superuser = User.objects.create( 3470 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3471 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3472 first_name='Super', last_name='User', email='super@example.com', 3473 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3474 ) 3341 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3475 3342 3476 3343 def setUp(self): 3477 result = self.client.login(username='super', password='secret') 3478 self.assertEqual(result, True) 3344 self.client.force_login(self.superuser) 3479 3345 3480 3346 def test_custom_changelist(self): 3481 3347 """ … … class TestCustomChangeList(TestCase): 3493 3359 self.assertNotContains(response, 'First Gadget') 3494 3360 3495 3361 3496 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3497 ROOT_URLCONF="admin_views.urls") 3362 @override_settings(ROOT_URLCONF='admin_views.urls') 3498 3363 class TestInlineNotEditable(TestCase): 3499 3364 3500 3365 @classmethod 3501 3366 def setUpTestData(cls): 3502 cls.superuser = User.objects.create( 3503 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3504 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3505 first_name='Super', last_name='User', email='super@example.com', 3506 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3507 ) 3367 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3508 3368 3509 3369 def setUp(self): 3510 result = self.client.login(username='super', password='secret') 3511 self.assertEqual(result, True) 3370 self.client.force_login(self.superuser) 3512 3371 3513 3372 def test_GET_parent_add(self): 3514 3373 """ … … class TestInlineNotEditable(TestCase): 3518 3377 self.assertEqual(response.status_code, 200) 3519 3378 3520 3379 3521 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3522 ROOT_URLCONF="admin_views.urls") 3380 @override_settings(ROOT_URLCONF='admin_views.urls') 3523 3381 class AdminCustomQuerysetTest(TestCase): 3524 3382 3525 3383 @classmethod 3526 3384 def setUpTestData(cls): 3527 cls.superuser = User.objects.create( 3528 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3529 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3530 first_name='Super', last_name='User', email='super@example.com', 3531 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3532 ) 3385 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3533 3386 3534 3387 def setUp(self): 3535 3388 self.client.force_login(self.superuser) … … class AdminCustomQuerysetTest(TestCase): 3787 3640 ) 3788 3641 3789 3642 3790 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3791 ROOT_URLCONF="admin_views.urls") 3643 @override_settings(ROOT_URLCONF='admin_views.urls') 3792 3644 class AdminInlineFileUploadTest(TestCase): 3793 3645 3794 3646 @classmethod 3795 3647 def setUpTestData(cls): 3796 cls.superuser = User.objects.create( 3797 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3798 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3799 first_name='Super', last_name='User', email='super@example.com', 3800 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3801 ) 3648 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3802 3649 3803 3650 def setUp(self): 3804 3651 self.client.force_login(self.superuser) … … class AdminInlineFileUploadTest(TestCase): 3839 3686 self.assertContains(response, b"Currently") 3840 3687 3841 3688 3842 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 3843 ROOT_URLCONF="admin_views.urls") 3689 @override_settings(ROOT_URLCONF='admin_views.urls') 3844 3690 class AdminInlineTests(TestCase): 3845 3691 3846 3692 @classmethod 3847 3693 def setUpTestData(cls): 3848 cls.superuser = User.objects.create( 3849 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 3850 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 3851 first_name='Super', last_name='User', email='super@example.com', 3852 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 3853 ) 3694 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 3854 3695 3855 3696 def setUp(self): 3856 3697 self.post_data = { … … class AdminInlineTests(TestCase): 3938 3779 "category_set-2-collector": "1", 3939 3780 } 3940 3781 3941 result = self.client.login(username='super', password='secret') 3942 self.assertEqual(result, True) 3782 self.client.force_login(self.superuser) 3943 3783 self.collector = Collector(pk=1, name='John Fowles') 3944 3784 self.collector.save() 3945 3785 … … class AdminInlineTests(TestCase): 4165 4005 self.assertEqual(Category.objects.get(id=4).order, 0) 4166 4006 4167 4007 4168 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4169 ROOT_URLCONF="admin_views.urls") 4008 @override_settings(ROOT_URLCONF='admin_views.urls') 4170 4009 class NeverCacheTests(TestCase): 4171 4010 4172 4011 @classmethod 4173 4012 def setUpTestData(cls): 4174 cls.superuser = User.objects.create( 4175 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4176 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4177 first_name='Super', last_name='User', email='super@example.com', 4178 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4179 ) 4013 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4180 4014 cls.s1 = Section.objects.create(name='Test section') 4181 4015 4182 4016 def setUp(self): … … class NeverCacheTests(TestCase): 4245 4079 self.assertEqual(get_max_age(response), None) 4246 4080 4247 4081 4248 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4249 ROOT_URLCONF="admin_views.urls") 4082 @override_settings(ROOT_URLCONF='admin_views.urls') 4250 4083 class PrePopulatedTest(TestCase): 4251 4084 4252 4085 @classmethod 4253 4086 def setUpTestData(cls): 4254 cls.superuser = User.objects.create( 4255 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4256 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4257 first_name='Super', last_name='User', email='super@example.com', 4258 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4259 ) 4087 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4260 4088 cls.p1 = PrePopulatedPost.objects.create(title='A Long Title', published=True, slug='a-long-title') 4261 4089 4262 4090 def setUp(self): … … class PrePopulatedTest(TestCase): 4288 4116 self.assertContains(response, ""maxLength": 1000") # instead of 1,000 4289 4117 4290 4118 4291 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4292 ROOT_URLCONF="admin_views.urls") 4119 @override_settings(ROOT_URLCONF='admin_views.urls') 4293 4120 class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase): 4294 4121 4295 4122 available_apps = ['admin_views'] + AdminSeleniumWebDriverTestCase.available_apps 4296 4123 webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' 4297 4124 4298 4125 def setUp(self): 4299 self.superuser = User.objects.create( 4300 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4301 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4302 first_name='Super', last_name='User', email='super@example.com', 4303 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4304 ) 4126 self.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4305 4127 self.p1 = PrePopulatedPost.objects.create(title='A Long Title', published=True, slug='a-long-title') 4306 4128 4307 4129 def test_prepopulated_fields(self): … … class SeleniumAdminViewsIETests(SeleniumAdminViewsFirefoxTests): 4629 4451 webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' 4630 4452 4631 4453 4632 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4633 ROOT_URLCONF="admin_views.urls") 4454 @override_settings(ROOT_URLCONF='admin_views.urls') 4634 4455 class ReadonlyTest(AdminFieldExtractionMixin, TestCase): 4635 4456 4636 4457 @classmethod 4637 4458 def setUpTestData(cls): 4638 cls.superuser = User.objects.create( 4639 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4640 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4641 first_name='Super', last_name='User', email='super@example.com', 4642 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4643 ) 4459 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4644 4460 4645 4461 def setUp(self): 4646 4462 self.client.force_login(self.superuser) … … class ReadonlyTest(AdminFieldExtractionMixin, TestCase): 4805 4621 self.assertContains(response, "<a>evil</a>", status_code=200) 4806 4622 4807 4623 4808 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4809 ROOT_URLCONF="admin_views.urls") 4624 @override_settings(ROOT_URLCONF='admin_views.urls') 4810 4625 class LimitChoicesToInAdminTest(TestCase): 4811 4626 4812 4627 @classmethod 4813 4628 def setUpTestData(cls): 4814 cls.superuser = User.objects.create( 4815 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4816 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4817 first_name='Super', last_name='User', email='super@example.com', 4818 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4819 ) 4629 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4820 4630 4821 4631 def setUp(self): 4822 4632 self.client.force_login(self.superuser) … … class LimitChoicesToInAdminTest(TestCase): 4837 4647 self.assertNotContains(response, marley.username) 4838 4648 4839 4649 4840 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4841 ROOT_URLCONF="admin_views.urls") 4650 @override_settings(ROOT_URLCONF='admin_views.urls') 4842 4651 class RawIdFieldsTest(TestCase): 4843 4652 4844 4653 @classmethod 4845 4654 def setUpTestData(cls): 4846 cls.superuser = User.objects.create( 4847 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4848 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4849 first_name='Super', last_name='User', email='super@example.com', 4850 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4851 ) 4655 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4852 4656 4853 4657 def setUp(self): 4854 4658 self.client.force_login(self.superuser) … … class RawIdFieldsTest(TestCase): 4932 4736 self.assertContains(response, 'list-display-sketch') 4933 4737 4934 4738 4935 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 4936 ROOT_URLCONF="admin_views.urls") 4739 @override_settings(ROOT_URLCONF='admin_views.urls') 4937 4740 class UserAdminTest(TestCase): 4938 4741 """ 4939 4742 Tests user CRUD functionality. … … class UserAdminTest(TestCase): 4941 4744 4942 4745 @classmethod 4943 4746 def setUpTestData(cls): 4944 cls.superuser = User.objects.create( 4945 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4946 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 4947 first_name='Super', last_name='User', email='super@example.com', 4948 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4949 ) 4950 cls.adduser = User.objects.create( 4951 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4952 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='adduser', 4953 first_name='Add', last_name='User', email='auser@example.com', 4954 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4955 ) 4956 cls.changeuser = User.objects.create( 4957 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 4958 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='changeuser', 4959 first_name='Change', last_name='User', email='cuser@example.com', 4960 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 4961 ) 4747 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 4748 cls.adduser = User.objects.create_user(username='adduser', password='secret', is_staff=True) 4749 cls.changeuser = User.objects.create_user(username='changeuser', password='secret', is_staff=True) 4962 4750 cls.s1 = Section.objects.create(name='Test section') 4963 4751 cls.a1 = Article.objects.create( 4964 4752 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … class UserAdminTest(TestCase): 5104 4892 self.assertEqual(response.context['form_url'], 'pony') 5105 4893 5106 4894 5107 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5108 ROOT_URLCONF="admin_views.urls") 4895 @override_settings(ROOT_URLCONF='admin_views.urls') 5109 4896 class GroupAdminTest(TestCase): 5110 4897 """ 5111 4898 Tests group CRUD functionality. … … class GroupAdminTest(TestCase): 5113 4900 5114 4901 @classmethod 5115 4902 def setUpTestData(cls): 5116 cls.superuser = User.objects.create( 5117 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5118 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5119 first_name='Super', last_name='User', email='super@example.com', 5120 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5121 ) 4903 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5122 4904 5123 4905 def setUp(self): 5124 4906 self.client.force_login(self.superuser) … … class GroupAdminTest(TestCase): 5144 4926 self.assertEqual(response.status_code, 200) 5145 4927 5146 4928 5147 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5148 ROOT_URLCONF="admin_views.urls") 4929 @override_settings(ROOT_URLCONF='admin_views.urls') 5149 4930 class CSSTest(TestCase): 5150 4931 5151 4932 @classmethod 5152 4933 def setUpTestData(cls): 5153 cls.superuser = User.objects.create( 5154 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5155 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5156 first_name='Super', last_name='User', email='super@example.com', 5157 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5158 ) 4934 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5159 4935 cls.s1 = Section.objects.create(name='Test section') 5160 4936 cls.a1 = Article.objects.create( 5161 4937 content='<p>Middle content</p>', date=datetime.datetime(2008, 3, 18, 11, 54, 58), section=cls.s1 … … except ImportError: 5281 5057 5282 5058 5283 5059 @unittest.skipUnless(docutils, "no docutils installed.") 5284 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5285 ROOT_URLCONF="admin_views.urls") 5060 @override_settings(ROOT_URLCONF='admin_views.urls') 5286 5061 @modify_settings(INSTALLED_APPS={'append': ['django.contrib.admindocs', 'django.contrib.flatpages']}) 5287 5062 class AdminDocsTest(TestCase): 5288 5063 5289 5064 @classmethod 5290 5065 def setUpTestData(cls): 5291 cls.superuser = User.objects.create( 5292 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5293 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5294 first_name='Super', last_name='User', email='super@example.com', 5295 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5296 ) 5066 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5297 5067 5298 5068 def setUp(self): 5299 5069 self.client.force_login(self.superuser) … … class AdminDocsTest(TestCase): 5331 5101 5332 5102 5333 5103 @override_settings( 5334 PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5335 ROOT_URLCONF="admin_views.urls", 5104 ROOT_URLCONF='admin_views.urls', 5336 5105 TEMPLATES=[{ 5337 5106 'BACKEND': 'django.template.backends.django.DjangoTemplates', 5338 5107 'APP_DIRS': True, … … class ValidXHTMLTests(TestCase): 5351 5120 5352 5121 @classmethod 5353 5122 def setUpTestData(cls): 5354 cls.superuser = User.objects.create( 5355 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5356 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5357 first_name='Super', last_name='User', email='super@example.com', 5358 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5359 ) 5123 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5360 5124 5361 5125 def setUp(self): 5362 5126 self.client.force_login(self.superuser) … … class ValidXHTMLTests(TestCase): 5367 5131 self.assertNotContains(response, ' xml:lang=""') 5368 5132 5369 5133 5370 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5371 ROOT_URLCONF="admin_views.urls", 5372 USE_THOUSAND_SEPARATOR=True, USE_L10N=True) 5134 @override_settings(ROOT_URLCONF='admin_views.urls', USE_THOUSAND_SEPARATOR=True, USE_L10N=True) 5373 5135 class DateHierarchyTests(TestCase): 5374 5136 5375 5137 @classmethod 5376 5138 def setUpTestData(cls): 5377 cls.superuser = User.objects.create( 5378 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5379 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5380 first_name='Super', last_name='User', email='super@example.com', 5381 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5382 ) 5139 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5383 5140 5384 5141 def setUp(self): 5385 5142 self.client.force_login(self.superuser) … … class DateHierarchyTests(TestCase): 5498 5255 self.assert_non_localized_year(response, 2005) 5499 5256 5500 5257 5501 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5502 ROOT_URLCONF="admin_views.urls") 5258 @override_settings(ROOT_URLCONF='admin_views.urls') 5503 5259 class AdminCustomSaveRelatedTests(TestCase): 5504 5260 """ 5505 5261 Ensure that one can easily customize the way related objects are saved. … … class AdminCustomSaveRelatedTests(TestCase): 5508 5264 5509 5265 @classmethod 5510 5266 def setUpTestData(cls): 5511 cls.superuser = User.objects.create( 5512 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5513 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5514 first_name='Super', last_name='User', email='super@example.com', 5515 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5516 ) 5267 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5517 5268 5518 5269 def setUp(self): 5519 5270 self.client.force_login(self.superuser) … … class AdminCustomSaveRelatedTests(TestCase): 5575 5326 self.assertEqual(['Catherine Stone', 'Paul Stone'], children_names) 5576 5327 5577 5328 5578 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5579 ROOT_URLCONF="admin_views.urls") 5329 @override_settings(ROOT_URLCONF='admin_views.urls') 5580 5330 class AdminViewLogoutTests(TestCase): 5581 5331 5582 5332 @classmethod 5583 5333 def setUpTestData(cls): 5584 cls.superuser = User.objects.create( 5585 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5586 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5587 first_name='Super', last_name='User', email='super@example.com', 5588 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5589 ) 5334 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5590 5335 5591 5336 def test_logout(self): 5592 5337 self.client.force_login(self.superuser) … … class AdminViewLogoutTests(TestCase): 5609 5354 self.assertContains(response, '<input type="hidden" name="next" value="%s" />' % reverse('admin:index')) 5610 5355 5611 5356 5612 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5613 ROOT_URLCONF="admin_views.urls") 5357 @override_settings(ROOT_URLCONF='admin_views.urls') 5614 5358 class AdminUserMessageTest(TestCase): 5615 5359 5616 5360 @classmethod 5617 5361 def setUpTestData(cls): 5618 cls.superuser = User.objects.create( 5619 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5620 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5621 first_name='Super', last_name='User', email='super@example.com', 5622 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5623 ) 5362 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5624 5363 5625 5364 def setUp(self): 5626 5365 self.client.force_login(self.superuser) … … class AdminUserMessageTest(TestCase): 5672 5411 html=True) 5673 5412 5674 5413 5675 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5676 ROOT_URLCONF="admin_views.urls") 5414 @override_settings(ROOT_URLCONF='admin_views.urls') 5677 5415 class AdminKeepChangeListFiltersTests(TestCase): 5678 5416 admin_site = site 5679 5417 5680 5418 @classmethod 5681 5419 def setUpTestData(cls): 5682 cls.superuser = User.objects.create( 5683 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5684 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5685 first_name='Super', last_name='User', email='super@example.com', 5686 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5687 ) 5688 cls.joepublicuser = User.objects.create( 5689 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5690 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=False, username='joepublic', 5691 first_name='Joe', last_name='Public', email='joepublic@example.com', 5692 is_staff=False, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5693 ) 5420 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5421 cls.joepublicuser = User.objects.create_user(username='joepublic', password='secret') 5694 5422 5695 5423 def setUp(self): 5696 5424 self.client.force_login(self.superuser) … … class AdminKeepChangeListFiltersTests(TestCase): 5821 5549 def test_changelist_view(self): 5822 5550 response = self.client.get(self.get_changelist_url()) 5823 5551 self.assertEqual(response.status_code, 200) 5824 5825 5552 # Check the `change_view` link has the correct querystring. 5826 5553 detail_link = re.search( 5827 5554 '<a href="(.*?)">{}</a>'.format(self.joepublicuser.username), … … class NamespacedAdminKeepChangeListFiltersTests(AdminKeepChangeListFiltersTests) 5976 5703 admin_site = site2 5977 5704 5978 5705 5979 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 5980 ROOT_URLCONF="admin_views.urls") 5706 @override_settings(ROOT_URLCONF='admin_views.urls') 5981 5707 class TestLabelVisibility(TestCase): 5982 5708 """ #11277 -Labels of hidden fields in admin were not hidden. """ 5983 5709 5984 5710 @classmethod 5985 5711 def setUpTestData(cls): 5986 cls.superuser = User.objects.create( 5987 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 5988 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 5989 first_name='Super', last_name='User', email='super@example.com', 5990 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 5991 ) 5712 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 5992 5713 5993 5714 def setUp(self): 5994 5715 self.client.force_login(self.superuser) … … class TestLabelVisibility(TestCase): 6024 5745 self.assertContains(response, '<div class="form-row hidden') 6025 5746 6026 5747 6027 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 6028 ROOT_URLCONF="admin_views.urls") 5748 @override_settings(ROOT_URLCONF='admin_views.urls') 6029 5749 class AdminViewOnSiteTests(TestCase): 6030 5750 6031 5751 @classmethod 6032 5752 def setUpTestData(cls): 6033 cls.superuser = User.objects.create( 6034 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 6035 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 6036 first_name='Super', last_name='User', email='super@example.com', 6037 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 6038 ) 5753 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 6039 5754 6040 5755 cls.s1 = State.objects.create(name='New York') 6041 5756 cls.s2 = State.objects.create(name='Illinois') … … class AdminViewOnSiteTests(TestCase): 6161 5876 self.assertIsNone(model_admin.get_view_on_site_url(Worker())) 6162 5877 6163 5878 6164 @override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 6165 ROOT_URLCONF="admin_views.urls") 5879 @override_settings(ROOT_URLCONF='admin_views.urls') 6166 5880 class InlineAdminViewOnSiteTest(TestCase): 6167 5881 6168 5882 @classmethod 6169 5883 def setUpTestData(cls): 6170 cls.superuser = User.objects.create( 6171 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 6172 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 6173 first_name='Super', last_name='User', email='super@example.com', 6174 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 6175 ) 5884 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 6176 5885 6177 5886 cls.s1 = State.objects.create(name='New York') 6178 5887 cls.s2 = State.objects.create(name='Illinois') … … class InlineAdminViewOnSiteTest(TestCase): 6211 5920 self.assertContains(response, '"/worker_inline/%s/%s/"' % (self.w1.surname, self.w1.name)) 6212 5921 6213 5922 6214 @override_settings(ROOT_URLCONF= "admin_views.urls")5923 @override_settings(ROOT_URLCONF='admin_views.urls') 6215 5924 class TestEtagWithAdminView(SimpleTestCase): 6216 5925 # See https://code.djangoproject.com/ticket/16003 6217 5926 … … class TestEtagWithAdminView(SimpleTestCase): 6227 5936 self.assertTrue(response.has_header('ETag')) 6228 5937 6229 5938 6230 @override_settings( 6231 PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], 6232 ROOT_URLCONF="admin_views.urls", 6233 ) 5939 @override_settings(ROOT_URLCONF='admin_views.urls') 6234 5940 class GetFormsetsWithInlinesArgumentTest(TestCase): 6235 5941 """ 6236 5942 #23934 - When adding a new model instance in the admin, the 'obj' argument … … class GetFormsetsWithInlinesArgumentTest(TestCase): 6242 5948 6243 5949 @classmethod 6244 5950 def setUpTestData(cls): 6245 cls.superuser = User.objects.create( 6246 password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', 6247 last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), is_superuser=True, username='super', 6248 first_name='Super', last_name='User', email='super@example.com', 6249 is_staff=True, is_active=True, date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) 6250 ) 5951 cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') 6251 5952 6252 5953 def setUp(self): 6253 5954 self.client.force_login(self.superuser)