File: test_gzipper.py

package info (click to toggle)
paste 2.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,396 kB
  • ctags: 2,615
  • sloc: python: 18,659; makefile: 17; sh: 7
file content (19 lines) | stat: -rw-r--r-- 595 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from paste.fixture import TestApp
from paste.gzipper import middleware
import gzip
import six

def simple_app(environ, start_response):
    start_response('200 OK', [('content-type', 'text/plain')])
    return [b'this is a test']

wsgi_app = middleware(simple_app)
app = TestApp(wsgi_app)

def test_gzip():
    res = app.get(
        '/', extra_environ=dict(HTTP_ACCEPT_ENCODING='gzip'))
    assert int(res.header('content-length')) == len(res.body)
    assert res.body != b'this is a test'
    actual = gzip.GzipFile(fileobj=six.BytesIO(res.body)).read()
    assert actual == b'this is a test'