diff options
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -130,6 +130,9 @@ class Result: if not found: self.testcase.fail("header %s not found" % name) + def get_data(self): + return "".join(self.writtendata) + "".join(self.returneddata) + from wsgitools import applications class StaticContentTest(unittest.TestCase): @@ -340,6 +343,20 @@ class BasicAuthMiddlewareTest(unittest.TestCase): def test401authfail(self): self.doauth(password="spam", status=401) +from wsgitools import filters +import gzip + +class GzipWSGIFilterTest(unittest.TestCase): + def testSimple(self): + app = applications.StaticContent("200 Found", + [("Content-Type", "text/plain")], "nothing") + app = filters.WSGIFilterMiddleware(app, filters.GzipWSGIFilter) + req = Request(self) + req.environ["HTTP_ACCEPT_ENCODING"] = "gzip" + res = req(app) + data = gzip.GzipFile(fileobj=io.StringIO(res.get_data())).read() + self.assertEqual(data, "nothing") + def alltests(case): return unittest.TestLoader().loadTestsFromTestCase(case) @@ -351,6 +368,7 @@ fullsuite.addTest(alltests(AuthDigestMiddlewareTest)) fullsuite.addTest(alltests(ContentLengthMiddlewareTest)) fullsuite.addTest(alltests(BasicAuthMiddlewareTest)) fullsuite.addTest(alltests(NoWriteCallableMiddlewareTest)) +fullsuite.addTest(alltests(GzipWSGIFilterTest)) if __name__ == "__main__": runner = unittest.TextTestRunner(verbosity=2) |