1477
1477
response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data)
1478
1478
self.failUnlessEqual(response.status_code, 302)
1480
def test_default_redirect(self):
1482
Test that actions which don't return an HttpResponse are redirected to
1483
the same page, retaining the querystring (which may contain changelist
1487
ACTION_CHECKBOX_NAME: [1],
1488
'action' : 'external_mail',
1491
url = '/test_admin/admin/admin_views/externalsubscriber/?ot=asc&o=1'
1492
response = self.client.post(url, action_data)
1493
self.assertRedirects(response, url)
1480
1495
def test_model_without_action(self):
1481
1496
"Tests a ModelAdmin without any action"
1482
1497
response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/')
2113
2128
response = self.client.get('/test_admin/admin/admin_views/pizza/add/')
2114
2129
self.assertEqual(response.status_code, 200)
2116
class IncompleteFormTest(TestCase):
2131
class UserAdminTest(TestCase):
2118
Tests validation of a ModelForm that doesn't explicitly have all data
2119
corresponding to model fields. Model validation shouldn't fail
2133
Tests user CRUD functionality.
2122
2135
fixtures = ['admin-views-users.xml']
2149
2164
self.assert_('password' not in adminform.form.errors)
2150
2165
self.assertEquals(adminform.form.errors['password2'],
2151
2166
[u"The two password fields didn't match."])
2168
def test_user_fk_popup(self):
2169
response = self.client.get('/test_admin/admin/admin_views/album/add/')
2170
self.failUnlessEqual(response.status_code, 200)
2171
self.assertContains(response, '/test_admin/admin/auth/user/add')
2172
self.assertContains(response, 'class="add-another" id="add_id_owner" onclick="return showAddAnotherPopup(this);"')
2173
response = self.client.get('/test_admin/admin/auth/user/add/?_popup=1')
2174
self.assertNotContains(response, 'name="_continue"')
2176
def test_user_add_another(self):
2177
user_count = User.objects.count()
2178
response = self.client.post('/test_admin/admin/auth/user/add/', {
2179
'username': 'newuser',
2180
'password1': 'newpassword',
2181
'password2': 'newpassword',
2184
new_user = User.objects.order_by('-id')[0]
2185
self.assertRedirects(response, '/test_admin/admin/auth/user/add/')
2186
self.assertEquals(User.objects.count(), user_count + 1)
2187
self.assertNotEquals(new_user.password, UNUSABLE_PASSWORD)
2190
# If docutils isn't installed, skip the AdminDocs tests.
2193
class AdminDocsTest(TestCase):
2194
fixtures = ['admin-views-users.xml']
2197
self.client.login(username='super', password='secret')
2200
self.client.logout()
2202
def test_tags(self):
2203
response = self.client.get('/test_admin/admin/doc/tags/')
2205
# The builtin tag group exists
2206
self.assertContains(response, "<h2>Built-in tags</h2>", count=2)
2208
# A builtin tag exists in both the index and detail
2209
self.assertContains(response, '<h3 id="built_in-autoescape">autoescape</h3>')
2210
self.assertContains(response, '<li><a href="#built_in-autoescape">autoescape</a></li>')
2212
# An app tag exists in both the index and detail
2213
self.assertContains(response, '<h3 id="comments-get_comment_count">get_comment_count</h3>')
2214
self.assertContains(response, '<li><a href="#comments-get_comment_count">get_comment_count</a></li>')
2216
# The admin list tag group exists
2217
self.assertContains(response, "<h2>admin_list</h2>", count=2)
2219
# An admin list tag exists in both the index and detail
2220
self.assertContains(response, '<h3 id="admin_list-admin_actions">admin_actions</h3>')
2221
self.assertContains(response, '<li><a href="#admin_list-admin_actions">admin_actions</a></li>')
2223
def test_filters(self):
2224
response = self.client.get('/test_admin/admin/doc/filters/')
2226
# The builtin filter group exists
2227
self.assertContains(response, "<h2>Built-in filters</h2>", count=2)
2229
# A builtin filter exists in both the index and detail
2230
self.assertContains(response, '<h3 id="built_in-add">add</h3>')
2231
self.assertContains(response, '<li><a href="#built_in-add">add</a></li>')