[Checkins] SVN: zope.app.wsgi/branches/sylvain-testlayers/ Cleaned tests. Had to remove a bit that was no longer relevant.

Souheil CHELFOUH souheil at chelfouh.com
Thu Feb 18 07:54:01 EST 2010


Log message for revision 109120:
  Cleaned tests. Had to remove a bit that was no longer relevant.
  This looks proper, but the tests are weak.
  

Changed:
  U   zope.app.wsgi/branches/sylvain-testlayers/buildout.cfg
  U   zope.app.wsgi/branches/sylvain-testlayers/setup.py
  U   zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/README.txt
  U   zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/tests.py

-=-
Modified: zope.app.wsgi/branches/sylvain-testlayers/buildout.cfg
===================================================================
--- zope.app.wsgi/branches/sylvain-testlayers/buildout.cfg	2010-02-18 12:44:11 UTC (rev 109119)
+++ zope.app.wsgi/branches/sylvain-testlayers/buildout.cfg	2010-02-18 12:54:00 UTC (rev 109120)
@@ -1,8 +1,12 @@
 [buildout]
 develop = . 
 parts = test
+extensions = mr.developer
+auto-checkout = zope.app.appsetup
 
+[sources]
+zope.app.appsetup = svn svn+ssh://svn.zope.org/repos/main/zope.app.appsetup/trunk
+
 [test]
 recipe = zc.recipe.testrunner
 eggs = zope.app.wsgi [test]
-

Modified: zope.app.wsgi/branches/sylvain-testlayers/setup.py
===================================================================
--- zope.app.wsgi/branches/sylvain-testlayers/setup.py	2010-02-18 12:44:11 UTC (rev 109119)
+++ zope.app.wsgi/branches/sylvain-testlayers/setup.py	2010-02-18 12:54:00 UTC (rev 109120)
@@ -44,21 +44,40 @@
       packages=find_packages('src'),
       package_dir = {'': 'src'},
       namespace_packages=['zope', 'zope.app'],
-      extras_require = dict(test=['zope.app.testing',
-                                  'zope.app.securitypolicy',
-                                  'zope.app.zcmlfiles',
-                                  'zope.testbrowser']),
-      install_requires=['setuptools',
-                        'wsgi_intercept',
-                        'ZConfig',
-                        'zope.app.appsetup >= 3.11.0',
-                        'zope.processlifetime',
-                        'zope.app.publication',
-                        'zope.event',
-                        'zope.interface',
-                        'zope.publisher',
-                        'zope.security',
-                        ],
+      extras_require = dict(test=[
+          'zope.annotation',
+          'zope.authentication',
+          'zope.browserpage',
+          'zope.componentvocabulary',
+          'zope.location',
+          'zope.login',
+          'zope.password',
+          'zope.principalregistry',
+          'zope.securitypolicy',
+          ]),
+      install_requires=[
+          'setuptools',
+          'ZConfig',
+          'wsgi_intercept',
+          'ZODB3',
+          'zope.app.appsetup >= 3.11.0',
+          'zope.processlifetime',
+          'zope.app.publication',
+          'zope.event',
+          'zope.interface',
+          'zope.publisher',
+          'zope.security',
+          'zope.component',
+          'zope.configuration',
+          'zope.container',
+          'zope.error',
+          'zope.lifecycleevent',
+          'zope.session',
+          'zope.site',
+          'zope.testbrowser',
+          'zope.testing',
+          'zope.traversing',
+          ],
       entry_points={
           'paste.app_factory': [
               'main = zope.app.wsgi.paste:ZopeApplication'

Modified: zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/README.txt
===================================================================
--- zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/README.txt	2010-02-18 12:44:11 UTC (rev 109119)
+++ zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/README.txt	2010-02-18 12:54:00 UTC (rev 109120)
@@ -47,8 +47,8 @@
 Now we can send the fabricated HTTP request to the application for processing:
 
   >>> print ''.join(app(environ, start_response))
-  <html><head><title>ComponentLookupError</title></head>
-  <body><h2>ComponentLookupError</h2>
+  <html><head><title>SystemError</title></head>
+  <body><h2>SystemError</h2>
   A server error occurred.
   </body></html>
   <BLANKLINE>
@@ -100,46 +100,15 @@
 environ after being sent to the app and also see that a key has been set to
 store user names for use in access logs.
 
-The key points be default to ``-`` if no user info is found:
+This logging information is provided by an adapter registered for
+`ILoggingInfo`. Out-of-the-box, `zope.publisher` registers a base
+adapter that returns the principal id as value::
 
   >>> print environ
   {'wsgi.input': <cStringIO.StringI object at ...>,
-   'wsgi.logging_info': '-', 'PATH_INFO': '/'}
+   'wsgi.logging_info': 'zope.anybody', 'PATH_INFO': '/'}
 
-Since we do not have a principal available in this setup we simply provide
-a ILoggingInfo adapter for our missing principal e.g. None:
 
-  >>> import zope.interface
-  >>> import zope.component
-  >>> from zope.publisher.interfaces.logginginfo import ILoggingInfo
-  >>> from zope.security.interfaces import IPrincipal
-  >>> class LoggingInfoStub(object):
-  ...     zope.interface.implements(ILoggingInfo)
-  ...     zope.component.adapts(zope.interface.Interface)  
-  ...     def __init__(self, request):
-  ...         self.request = request 
-  ...     def getLogMessage(self):
-  ...         return 'foobar'
-
-Now register the ILoggingInfo adapter and check again:
-
-  >>> zope.component.provideAdapter(LoggingInfoStub) 
-  >>> print ''.join(app(environ, start_response))
-  <html><head><title>ComponentLookupError</title></head>
-  <body><h2>ComponentLookupError</h2>
-  A server error occurred.
-  </body></html>
-  <BLANKLINE>
-
-As you can see, the app is still not working but our ILoggingInfo stub get
-invoked and provides a custom logging_info message:
-
-  >>> print environ
-  {'wsgi.input': <cStringIO.StringI object at ...>,
-   'wsgi.logging_info': 'foobar',
-   'PATH_INFO': '/'}
-
-
 Creating A WSGI Application
 ---------------------------
 
@@ -182,6 +151,7 @@
   >>> import zope.component
   >>> from zope.app.wsgi.interfaces import IWSGIPublisherApplicationCreatedEvent
   >>> called = []
+
   >>> @zope.component.adapter(IWSGIPublisherApplicationCreatedEvent)
   ... def handler(event):
   ...     called.append(event)
@@ -206,6 +176,13 @@
   >>> import shutil
   >>> shutil.rmtree(temp_dir)
 
+We remove our handler::
+
+  >>> from zope.site.hooks import getSiteManager
+  >>> getSiteManager().unregisterHandler(handler)
+  True
+
+
 About WSGI
 ----------
 

Modified: zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/tests.py
===================================================================
--- zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/tests.py	2010-02-18 12:44:11 UTC (rev 109119)
+++ zope.app.wsgi/branches/sylvain-testlayers/src/zope/app/wsgi/tests.py	2010-02-18 12:54:00 UTC (rev 109120)
@@ -18,6 +18,7 @@
 import tempfile
 import unittest
 import re
+import zope.component
 
 from zope import component, interface
 from zope.component.testlayer import ZCMLFileLayer
@@ -29,16 +30,14 @@
 from zope.app.publication.requestpublicationregistry import factoryRegistry
 from zope.app.publication.requestpublicationfactories import BrowserFactory
 from zope.app.wsgi.testing import AppWSGILayer
-from zope.app.security.interfaces import IAuthentication
-from zope.app.security.principalregistry import principalRegistry
+from zope.authentication.interfaces import IAuthentication
+from zope.securitypolicy.tests import principalRegistry
 
 
 class WSGILayer(ZCMLFileLayer):
+    pass
 
-    def tearDown(self):
-        import pdb ; pdb.set_trace()
 
-
 class FileView:
 
     interface.implements(zope.publisher.interfaces.browser.IBrowserPublisher)



More information about the checkins mailing list