diff options
| author | Collin Anderson <cmawebsite@gmail.com> | 2015-01-03 12:06:24 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-01-05 10:51:52 -0500 |
| commit | 3d2cae0896ee8026d1c2c5d31e4c4c8f74f2fef4 (patch) | |
| tree | 1abf00da86cd8831b829124a32058ea589b78b3c /tests/wsgi/tests.py | |
| parent | 05f702b94ca4ad77236a1e299270e8014def02e6 (diff) | |
Fixed #24072 -- Added FileResponse for streaming binary files.
Diffstat (limited to 'tests/wsgi/tests.py')
| -rw-r--r-- | tests/wsgi/tests.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/wsgi/tests.py b/tests/wsgi/tests.py index e8f29c60d8..13760d0b61 100644 --- a/tests/wsgi/tests.py +++ b/tests/wsgi/tests.py @@ -51,6 +51,28 @@ class WSGITest(TestCase): bytes(response), b"Content-Type: text/html; charset=utf-8\r\n\r\nHello World!") + def test_file_wrapper(self): + """ + Verify that FileResponse uses wsgi.file_wrapper. + """ + class FileWrapper(object): + def __init__(self, filelike, blksize=8192): + filelike.close() + application = get_wsgi_application() + environ = RequestFactory()._base_environ( + PATH_INFO='/file/', + REQUEST_METHOD='GET', + **{'wsgi.file_wrapper': FileWrapper} + ) + response_data = {} + + def start_response(status, headers): + response_data['status'] = status + response_data['headers'] = headers + response = application(environ, start_response) + self.assertEqual(response_data['status'], '200 OK') + self.assertIsInstance(response, FileWrapper) + class GetInternalWSGIApplicationTest(unittest.TestCase): @override_settings(WSGI_APPLICATION="wsgi.wsgi.application") |
