Added template used assertions into many tests

This commit is contained in:
Karl Hobley 2014-06-02 15:23:32 +01:00
parent d9825e9531
commit 106b27a5a5
9 changed files with 148 additions and 65 deletions

View file

@ -12,7 +12,7 @@ class TestHome(TestCase):
# Login
login(self.client)
def test_status_code(self):
def test_simple(self):
response = self.client.get(reverse('wagtailadmin_home'))
self.assertEqual(response.status_code, 200)

View file

@ -46,8 +46,10 @@ class TestDocumentIndexView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_index'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/documents/index.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -74,8 +76,12 @@ class TestDocumentAddView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_add_document'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/documents/add.html')
# TODO: Test posting
class TestDocumentEditView(TestCase):
@ -88,8 +94,12 @@ class TestDocumentEditView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_edit_document', args=(self.document.id,)), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/documents/edit.html')
# TODO: Test posting
class TestDocumentDeleteView(TestCase):
@ -102,8 +112,12 @@ class TestDocumentDeleteView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_delete_document', args=(self.document.id,)), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/documents/confirm_delete.html')
# TODO: Test posting
class TestDocumentChooserView(TestCase):
@ -113,8 +127,11 @@ class TestDocumentChooserView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_chooser'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/chooser/chooser.html')
self.assertTemplateUsed(response, 'wagtaildocs/chooser/chooser.js')
def test_search(self):
response = self.get({'q': "Hello"})
@ -138,8 +155,12 @@ class TestDocumentChooserChosenView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_document_chosen', args=(self.document.id,)), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/chooser/document_chosen.js')
# TODO: Test posting
class TestDocumentChooserUploadView(TestCase):
@ -149,8 +170,13 @@ class TestDocumentChooserUploadView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtaildocs_chooser_upload'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtaildocs/chooser/chooser.html')
self.assertTemplateUsed(response, 'wagtaildocs/chooser/chooser.js')
# TODO: Test document upload with chooser
class TestDocumentFilenameProperties(TestCase):

View file

@ -194,8 +194,10 @@ class TestImageIndexView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailimages_index'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/images/index.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -225,8 +227,10 @@ class TestImageAddView(TestCase):
def post(self, post_data={}):
return self.client.post(reverse('wagtailimages_add_image'), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/images/add.html')
def test_add(self):
response = self.post({
@ -263,8 +267,10 @@ class TestImageEditView(TestCase):
def post(self, post_data={}):
return self.client.post(reverse('wagtailimages_edit_image', args=(self.image.id,)), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/images/edit.html')
def test_edit(self):
response = self.post({
@ -295,8 +301,10 @@ class TestImageDeleteView(TestCase):
def post(self, post_data={}):
return self.client.post(reverse('wagtailimages_delete_image', args=(self.image.id,)), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/images/confirm_delete.html')
def test_delete(self):
response = self.post({
@ -318,8 +326,11 @@ class TestImageChooserView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailimages_chooser'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/chooser/chooser.html')
self.assertTemplateUsed(response, 'wagtailimages/chooser/chooser.js')
def test_search(self):
response = self.get({'q': "Hello"})
@ -346,8 +357,12 @@ class TestImageChooserChosenView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailimages_image_chosen', args=(self.image.id,)), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/chooser/image_chosen.js')
# TODO: Test posting
class TestImageChooserUploadView(TestCase):
@ -357,5 +372,10 @@ class TestImageChooserUploadView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailimages_chooser_upload'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailimages/chooser/chooser.html')
self.assertTemplateUsed(response, 'wagtailimages/chooser/chooser.js')
# TODO: Test uploading through chooser

View file

@ -73,8 +73,10 @@ class TestRedirectsIndexView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailredirects_index'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailredirects/index.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -98,8 +100,10 @@ class TestRedirectsAddView(TestCase):
def post(self, post_data={}):
return self.client.post(reverse('wagtailredirects_add_redirect'), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailredirects/add.html')
def test_add(self):
response = self.post({
@ -142,8 +146,10 @@ class TestRedirectsEditView(TestCase):
def post(self, post_data={}, redirect_id=None):
return self.client.post(reverse('wagtailredirects_edit_redirect', args=(redirect_id or self.redirect.id, )), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailredirects/edit.html')
def test_nonexistant_redirect(self):
self.assertEqual(self.get(redirect_id=100000).status_code, 404)
@ -188,8 +194,10 @@ class TestRedirectsDeleteView(TestCase):
def post(self, post_data={}, redirect_id=None):
return self.client.post(reverse('wagtailredirects_delete_redirect', args=(redirect_id or self.redirect.id, )), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailredirects/confirm_delete.html')
def test_nonexistant_redirect(self):
self.assertEqual(self.get(redirect_id=100000).status_code, 404)

View file

@ -52,8 +52,10 @@ class TestEditorsPicksIndexView(TestCase):
def get(self, params={}):
return self.client.get('/admin/search/editorspicks/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/editorspicks/index.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -74,8 +76,10 @@ class TestEditorsPicksAddView(TestCase):
def get(self, params={}):
return self.client.get('/admin/search/editorspicks/add/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/editorspicks/add.html')
class TestEditorsPicksEditView(TestCase):
@ -89,8 +93,10 @@ class TestEditorsPicksEditView(TestCase):
def get(self, params={}):
return self.client.get('/admin/search/editorspicks/' + str(self.query.id) + '/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/editorspicks/edit.html')
class TestEditorsPicksDeleteView(TestCase):
@ -104,5 +110,7 @@ class TestEditorsPicksDeleteView(TestCase):
def get(self, params={}):
return self.client.get('/admin/search/editorspicks/' + str(self.query.id) + '/delete/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/editorspicks/confirm_delete.html')

View file

@ -5,8 +5,10 @@ class TestSearchView(TestCase):
def get(self, params={}):
return self.client.get('/search/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/search_results.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -24,8 +26,10 @@ class TestSuggestionsView(TestCase):
def get(self, params={}):
return self.client.get('/search/suggest/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
# TODO: Check that a valid JSON document was returned
def test_search(self):
response = self.get({'q': "Hello"})

View file

@ -146,8 +146,11 @@ class TestQueryChooserView(TestCase):
def get(self, params={}):
return self.client.get('/admin/search/queries/chooser/', params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsearch/queries/chooser/chooser.html')
self.assertTemplateUsed(response, 'wagtailsearch/queries/chooser/chooser.js')
def test_search(self):
response = self.get({'q': "Hello"})

View file

@ -13,8 +13,10 @@ class TestSnippetIndexView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailsnippets_index'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/index.html')
def test_displays_snippet(self):
self.assertContains(self.get(), "Adverts")
@ -29,8 +31,10 @@ class TestSnippetListView(TestCase):
args=('tests', 'advert')),
params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/type_index.html')
def test_displays_add_button(self):
self.assertContains(self.get(), "Add advert")
@ -50,8 +54,10 @@ class TestSnippetCreateView(TestCase):
args=('tests', 'advert')),
post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/create.html')
def test_create_invalid(self):
response = self.post(post_data={'foo': 'bar'})
@ -87,8 +93,10 @@ class TestSnippetEditView(TestCase):
args=('tests', 'advert', self.test_snippet.id)),
post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/edit.html')
def test_non_existant_model(self):
response = self.client.get(reverse('wagtailsnippets_edit',

View file

@ -11,8 +11,10 @@ class TestUserIndexView(TestCase):
def get(self, params={}):
return self.client.get(reverse('wagtailusers_index'), params)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailusers/index.html')
def test_search(self):
response = self.get({'q': "Hello"})
@ -36,8 +38,10 @@ class TestUserCreateView(TestCase):
def post(self, post_data={}):
return self.client.post(reverse('wagtailusers_create'), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailusers/create.html')
def test_create(self):
response = self.post({
@ -72,8 +76,10 @@ class TestUserEditView(TestCase):
def post(self, post_data={}, user_id=None):
return self.client.post(reverse('wagtailusers_edit', args=(user_id or self.test_user.id, )), post_data)
def test_status_code(self):
self.assertEqual(self.get().status_code, 200)
def test_simple(self):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailusers/edit.html')
def test_nonexistant_redirect(self):
self.assertEqual(self.get(user_id=100000).status_code, 404)