mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-29 02:54:49 +00:00
Additional tests for document.url and serve view behaviour
This commit is contained in:
parent
76d72a36c3
commit
cf8ca04cb4
1 changed files with 15 additions and 3 deletions
|
|
@ -73,6 +73,7 @@ class TestServeViewWithRedirect(TestCase):
|
|||
def setUp(self):
|
||||
self.document = models.Document(title="Test document")
|
||||
self.document.file.save('example.doc', ContentFile("A boring example document"))
|
||||
self.serve_view_url = reverse('wagtaildocs_serve', args=(self.document.id, self.document.filename))
|
||||
|
||||
def tearDown(self):
|
||||
self.document.delete()
|
||||
|
|
@ -80,6 +81,9 @@ class TestServeViewWithRedirect(TestCase):
|
|||
def get(self):
|
||||
return self.client.get(reverse('wagtaildocs_serve', args=(self.document.id, self.document.filename)))
|
||||
|
||||
def test_document_url_should_point_to_serve_view(self):
|
||||
self.assertEqual(self.document.url, self.serve_view_url)
|
||||
|
||||
def test_redirect(self):
|
||||
response = self.get()
|
||||
self.assertRedirects(response, self.document.file.url, fetch_redirect_response=False)
|
||||
|
|
@ -94,9 +98,18 @@ class TestDirectDocumentUrls(TestCase):
|
|||
def tearDown(self):
|
||||
self.document.delete()
|
||||
|
||||
def test_url(self):
|
||||
def get(self):
|
||||
return self.client.get(reverse('wagtaildocs_serve', args=(self.document.id, self.document.filename)))
|
||||
|
||||
def test_url_should_point_directly_to_file_storage_url(self):
|
||||
self.assertEqual(self.document.url, self.document.file.url)
|
||||
|
||||
def test_redirect(self):
|
||||
# The serve view will not normally be linked to in 'direct' mode, but we should ensure it
|
||||
# still works by redirecting
|
||||
response = self.get()
|
||||
self.assertRedirects(response, self.document.file.url, fetch_redirect_response=False)
|
||||
|
||||
|
||||
@override_settings(
|
||||
WAGTAILDOCS_SERVE_METHOD=None,
|
||||
|
|
@ -115,8 +128,7 @@ class TestServeWithExternalStorage(TestCase):
|
|||
def tearDown(self):
|
||||
self.document.delete()
|
||||
|
||||
def test_url(self):
|
||||
# document.url should point to the serve view
|
||||
def test_document_url_should_point_to_serve_view(self):
|
||||
self.assertEqual(self.document.url, self.serve_view_url)
|
||||
|
||||
def test_redirect(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue