| 1 |
import django_downloadview.apache.tests |
| 2 |
from django_downloadview.lighttpd.response import XSendfileResponse |
| 3 |
|
| 4 |
|
| 5 |
class XSendfileValidator(django_downloadview.apache.tests.XSendfileValidator): |
| 6 |
"""Utility class to validate XSendfileResponse instances. |
| 7 |
|
| 8 |
See also :py:func:`assert_x_sendfile` shortcut function. |
| 9 |
|
| 10 |
""" |
| 11 |
|
| 12 |
def assert_x_sendfile_response(self, test_case, response): |
| 13 |
test_case.assertTrue(isinstance(response, XSendfileResponse)) |
| 14 |
|
| 15 |
|
| 16 |
def assert_x_sendfile(test_case, response, **assertions): |
| 17 |
"""Make ``test_case`` assert that ``response`` is a XSendfileResponse. |
| 18 |
|
| 19 |
Optional ``assertions`` dictionary can be used to check additional items: |
| 20 |
|
| 21 |
* ``basename``: the basename of the file in the response. |
| 22 |
|
| 23 |
* ``content_type``: the value of "Content-Type" header. |
| 24 |
|
| 25 |
* ``file_path``: the value of "X-Sendfile" header. |
| 26 |
|
| 27 |
""" |
| 28 |
validator = XSendfileValidator() |
| 29 |
return validator(test_case, response, **assertions) |