def test_encode_content_gzip_notyet_gzipped(): res = Response() res.app_iter = io.BytesIO(b"foo") result = res.encode_content("gzip") eq_(result, None) eq_(res.content_length, 23) eq_(res.app_iter, [b"\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff", b"K\xcb\xcf\x07\x00", b"!es\x8c\x03\x00\x00\x00"])
def test_encode_content_gzip_buffer_coverage(): # this test is to provide 100% coverage of # Response.encode_content was necessary in order to get # request https://github.com/Pylons/webob/pull/85 into upstream res = Response() DATA = b"abcdefghijklmnopqrstuvwxyz0123456789" * 1000000 res.app_iter = io.BytesIO(DATA) res.encode_content('gzip') result = list(res.app_iter) assert len(b"".join(result)) < len(DATA)
def test_encode_content_gzip_notyet_gzipped_lazy(): res = Response() res.app_iter = io.BytesIO(b'foo') result = res.encode_content('gzip', lazy=True) eq_(result, None) eq_(res.content_length, None) eq_(list(res.app_iter), [ b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff', b'K\xcb\xcf\x07\x00', b'!es\x8c\x03\x00\x00\x00' ])
def test_encode_content_gzip_notyet_gzipped(): res = Response() res.app_iter = io.BytesIO(b'foo') result = res.encode_content('gzip') assert result is None assert res.content_length == 23 assert res.app_iter == [ b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff', b'K\xcb\xcf\x07\x00', b'!es\x8c\x03\x00\x00\x00' ]
def test_encode_content_gzip_notyet_gzipped_lazy(): res = Response() res.app_iter = io.BytesIO(b"foo") result = res.encode_content("gzip", lazy=True) assert result is None assert res.content_length is None assert list(res.app_iter) == [ b"\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff", b"K\xcb\xcf\x07\x00", b"!es\x8c\x03\x00\x00\x00", ]
def csv_download(self, request, *args, **kwargs): # pylint: disable=unused-argument """ Handles the CSV download request. """ local_datetime = request.params.get('local-datetime') local_timezone_offset = dateutil.parser.parse(local_datetime).tzinfo response = Response(content_type='text/csv') response.content_disposition = 'attachment; filename="short_answer_submissions.csv"' response.app_iter = self.create_csv(local_timezone_offset) return response