r47152 - tests

hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Tue, 5 Apr 2016 10:06:16 -0600 (MDT)
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: hawkowl
Date: Tue Apr  5 10:06:12 2016
New Revision: 47152

Modified:
   branches/dropped-factory-8272/twisted/web/test/test_http.py

Log:
tests

Modified: branches/dropped-factory-8272/twisted/web/test/test_http.py
==============================================================================
--- branches/dropped-factory-8272/twisted/web/test/test_http.py	(original)
+++ branches/dropped-factory-8272/twisted/web/test/test_http.py	Tue Apr  5 10:06:12 2016
@@ -14,7 +14,8 @@
 except ImportError:
     from urllib.parse import urlparse, urlunsplit, clear_cache
 
-from twisted.python.compat import _PY3, iterbytes, networkString, unicode, intToBytes
+from twisted.python.compat import (_PY3, iterbytes, networkString, unicode,
+                                   intToBytes, NativeStringIO)
 from twisted.python.failure import Failure
 from twisted.trial import unittest
 from twisted.trial.unittest import TestCase
@@ -2326,6 +2327,34 @@
         self.assertEqual((None, existing), (req.producer, transport.producer))
 
 
+    def test_finishProducesLog(self):
+        """
+        L{http.Request.finish} will call the channel's factory to produce a log
+        message.
+        """
+        factory = http.HTTPFactory()
+        factory._logDateTime = "sometime"
+        factory._logDateTimeCall = True
+        factory.startFactory()
+        factory.logFile = NativeStringIO()
+
+        channel = DummyChannel()
+        trans = StringTransport()
+        channel.transport = trans
+        channel.factory = factory
+        req = http.Request(channel, False)
+
+        req.gotLength(1)
+        req.requestReceived(b'GET', b'/path', b'HTTP/1.1')
+
+        req.write(b"blah")
+        req.finish()
+
+        # A log message should be written out
+        self.assertIn('sometime "GET /path HTTP/1.1"',
+                      factory.logFile.getvalue())
+
+
     def test_transportDeprecated(self):
         """
         L{http.Request.transport} will raise a L{DeprecationWarning} if