The static view should stream files in chunks to avoid large memory usage
(self)
| 39 | ) |
| 40 | |
| 41 | def test_chunked(self): |
| 42 | """ |
| 43 | The static view should stream files in chunks to avoid large memory |
| 44 | usage |
| 45 | """ |
| 46 | response = self.client.get("/%s/%s" % (self.prefix, "long-line.txt")) |
| 47 | response_iterator = iter(response) |
| 48 | first_chunk = next(response_iterator) |
| 49 | self.assertEqual(len(first_chunk), FileResponse.block_size) |
| 50 | second_chunk = next(response_iterator) |
| 51 | response.close() |
| 52 | # strip() to prevent OS line endings from causing differences |
| 53 | self.assertEqual(len(second_chunk.strip()), 1449) |
| 54 | |
| 55 | def test_unknown_mime_type(self): |
| 56 | response = self.client.get("/%s/file.unknown" % self.prefix) |