summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test.py b/test.py
index 1acf5aa..5a96f93 100755
--- a/test.py
+++ b/test.py
@@ -2,6 +2,7 @@
import unittest
import doctest
+import re
import wsgiref.validate
# Cannot use io module as it is broken in 2.6.
# Writing a str to a io.StringIO results in an exception.
@@ -346,6 +347,22 @@ class BasicAuthMiddlewareTest(unittest.TestCase):
from wsgitools import filters
import gzip
+class RequestLogWSGIFilterTest(unittest.TestCase):
+ def testSimple(self):
+ app = applications.StaticContent("200 Found",
+ [("Content-Type", "text/plain")], "nothing")
+ log = io.StringIO()
+ logfilter = filters.RequestLogWSGIFilter.creator(log)
+ app = filters.WSGIFilterMiddleware(app, logfilter)
+ req = Request(self)
+ req.environ["REMOTE_ADDR"] = "1.2.3.4"
+ req.environ["PATH_INFO"] = "/"
+ req.environ["HTTP_USER_AGENT"] = "wsgitools-test"
+ res = req(app)
+ logged = log.getvalue()
+ self.assert_(re.match(r'^1\.2\.3\.4 - - \[[^]]+\] "GET /" '
+ r'200 7 - "wsgitools-test"', logged))
+
class GzipWSGIFilterTest(unittest.TestCase):
def testSimple(self):
app = applications.StaticContent("200 Found",
@@ -368,6 +385,7 @@ fullsuite.addTest(alltests(AuthDigestMiddlewareTest))
fullsuite.addTest(alltests(ContentLengthMiddlewareTest))
fullsuite.addTest(alltests(BasicAuthMiddlewareTest))
fullsuite.addTest(alltests(NoWriteCallableMiddlewareTest))
+fullsuite.addTest(alltests(RequestLogWSGIFilterTest))
fullsuite.addTest(alltests(GzipWSGIFilterTest))
if __name__ == "__main__":