[Zope3-checkins] CVS: Zope3/src/zope/publisher/tests - test_http.py:1.18

Viktorija Zaksiene ryzaja@codeworks.lt
Tue, 22 Jul 2003 11:09:52 -0400


Update of /cvs-repository/Zope3/src/zope/publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv14056/src/zope/publisher/tests

Modified Files:
	test_http.py 
Log Message:
Vika and Bjorn Tillenius:
Made HTTPRequest.setUser use an adapter to choose what name to log. We don't want to
make policy decisions there.


=== Zope3/src/zope/publisher/tests/test_http.py 1.17 => 1.18 ===
--- Zope3/src/zope/publisher/tests/test_http.py:1.17	Tue Jul 22 05:33:40 2003
+++ Zope3/src/zope/publisher/tests/test_http.py	Tue Jul 22 11:09:47 2003
@@ -13,8 +13,12 @@
 ##############################################################################
 import unittest
 
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.interfaces.security import IPrincipal
+from zope.interface import Interface, implements
+from zope.component.adapter import provideAdapter
+from zope.publisher.interfaces.logginginfo import ILoggingInfo
 from zope.publisher.http import HTTPRequest
-
 from zope.publisher.publish import publish
 from zope.publisher.base import DefaultPublication
 from zope.publisher.interfaces.http import IHTTPPresentation, IHTTPRequest
@@ -25,13 +29,26 @@
 
 from StringIO import StringIO
 
+
+
 class UserStub:
+    implements(IPrincipal)
     def __init__(self, id):
         self._id = id
     def getId(self):
         return self._id
 
-class HTTPTests(unittest.TestCase):
+class PrincipalLoggingStub:
+    implements(ILoggingInfo)
+
+    def __init__(self, object):
+        self.object = object
+
+    def getLogMessage(self):
+        return self.object.getId()
+
+
+class HTTPTests(PlacefulSetup, unittest.TestCase):
 
     _testEnv =  {
         'PATH_INFO':          '/folder/item',
@@ -47,6 +64,7 @@
     }
 
     def setUp(self):
+        PlacefulSetup.setUp(self)
         class AppRoot:
             " "
 
@@ -208,6 +226,7 @@
             auth_user_name = None
             def setAuthUserName(self, name):
                 self.auth_user_name = name
+        provideAdapter(IPrincipal, ILoggingInfo, PrincipalLoggingStub)
         task = HTTPTaskStub()
         req = self._createRequest(outstream=task)
         req.setUser(UserStub("jim"))