FileResponse uses wsgi.file_wrapper.
(self)
| 63 | self.assertIn(("Set-Cookie", "key=value; Path=/"), response_data["headers"]) |
| 64 | |
| 65 | def test_file_wrapper(self): |
| 66 | """ |
| 67 | FileResponse uses wsgi.file_wrapper. |
| 68 | """ |
| 69 | |
| 70 | class FileWrapper: |
| 71 | def __init__(self, filelike, block_size=None): |
| 72 | self.block_size = block_size |
| 73 | filelike.close() |
| 74 | |
| 75 | application = get_wsgi_application() |
| 76 | environ = self.request_factory._base_environ( |
| 77 | PATH_INFO="/file/", |
| 78 | REQUEST_METHOD="GET", |
| 79 | **{"wsgi.file_wrapper": FileWrapper}, |
| 80 | ) |
| 81 | response_data = {} |
| 82 | |
| 83 | def start_response(status, headers): |
| 84 | response_data["status"] = status |
| 85 | response_data["headers"] = headers |
| 86 | |
| 87 | response = application(environ, start_response) |
| 88 | self.assertEqual(response_data["status"], "200 OK") |
| 89 | self.assertIsInstance(response, FileWrapper) |
| 90 | self.assertEqual(response.block_size, FileResponse.block_size) |
| 91 | |
| 92 | |
| 93 | class GetInternalWSGIApplicationTest(SimpleTestCase): |
nothing calls this directly
no test coverage detected