mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
Refs #80 - Added a test around demo's 'object:inline_file' URL.
This commit is contained in:
parent
ffef9ce703
commit
eeaabd2a37
4 changed files with 25 additions and 3 deletions
|
|
@ -68,3 +68,17 @@ class DeserializedBasenameTestCase(django.test.TestCase):
|
|||
content=file_content,
|
||||
basename=basename,
|
||||
mime_type='text/plain')
|
||||
|
||||
|
||||
class InlineFileTestCase(django.test.TestCase):
|
||||
@temporary_media_root()
|
||||
def test_download_response(self):
|
||||
"'inline_file_view' streams Document.file inline."
|
||||
setup_document()
|
||||
url = reverse('object:inline_file', kwargs={'slug': slug})
|
||||
response = self.client.get(url)
|
||||
assert_download_response(self,
|
||||
response,
|
||||
content=file_content,
|
||||
mime_type='text/plain',
|
||||
attachment=False)
|
||||
|
|
|
|||
|
|
@ -14,4 +14,7 @@ urlpatterns = patterns(
|
|||
url(r'^deserialized_basename/(?P<slug>[a-zA-Z0-9_-]+)/$',
|
||||
views.deserialized_basename_view,
|
||||
name='deserialized_basename'),
|
||||
url(r'^inline-file/(?P<slug>[a-zA-Z0-9_-]+)/$',
|
||||
views.inline_file_view,
|
||||
name='inline_file'),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -144,8 +144,13 @@ class DownloadResponseValidator(object):
|
|||
value)
|
||||
|
||||
def assert_attachment(self, test_case, response, value):
|
||||
test_case.assertEqual('attachment;' in response['Content-Disposition'],
|
||||
value)
|
||||
if value:
|
||||
test_case.assertTrue(
|
||||
'attachment;' in response['Content-Disposition'])
|
||||
else:
|
||||
test_case.assertTrue(
|
||||
'Content-Disposition' not in response
|
||||
or 'attachment;' not in response['Content-Disposition'])
|
||||
|
||||
|
||||
def assert_download_response(test_case, response, **assertions):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Setup a view to stream the ``file`` attribute:
|
|||
|
||||
.. literalinclude:: /../demo/demoproject/object/urls.py
|
||||
:language: python
|
||||
:lines: 1-7, 8-10, 17
|
||||
:lines: 1-7, 8-10, 20
|
||||
|
||||
|
||||
************
|
||||
|
|
|
|||
Loading…
Reference in a new issue