[Checkins] SVN: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/ Update tests to zope.app.wsgi instead of zope.app.testing/zope.app.zcmlfiles

Jan-Jaap Driessen jdriessen at thehealthagency.com
Fri Nov 12 10:44:24 EST 2010


Log message for revision 118373:
  Update tests to zope.app.wsgi instead of zope.app.testing/zope.app.zcmlfiles

Changed:
  U   hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt
  U   hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/ftesting.zcml
  U   hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/tests.py

-=-
Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt	2010-11-12 15:41:17 UTC (rev 118372)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt	2010-11-12 15:44:24 UTC (rev 118373)
@@ -2,15 +2,13 @@
 ***********************************
 
 This package provides Zope integration for hurry.resource. This means
-it's taking care of three things:
+it's taking care of two things:
 
-* maintain the needed resources throughout the request/response cycle.
+* provide access to the needed resources in the WSGI environment throughout
+  the request/response cycle.
 
-* know how to make a URL to a resource.
+* provide the base URL for the resources to be rendered.
 
-* make so that resource references are automatically inserted in the
-  HTML header.
-
 This library fulfills these conditions for a Zope Toolkit/Grok setup.
 
 We'll run through a few tests to demonstrate it. Note that the real
@@ -21,11 +19,11 @@
 a page we have set up in ``ftesting.zcml`` that should cause the
 inclusion of a single resource in its header::
 
-  >>> from zope.testbrowser.testing import Browser
+  >>> from zope.app.wsgi.testlayer import Browser
   >>> browser = Browser()
   >>> browser.handleErrors = False
   >>> browser.open('http://localhost/hurry.zoperesource.test_single')
-  >>> print browser.contents 
+  >>> print browser.contents
   <html>
   <head>
       <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
@@ -40,7 +38,7 @@
 automatically included::
 
   >>> browser.open('http://localhost/hurry.zoperesource.test_multiple')
-  >>> print browser.contents 
+  >>> print browser.contents
   <html>
   <head>
       <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
@@ -56,7 +54,7 @@
 the bottom now, just before the ``</body>`` tag::
 
   >>> browser.open('http://localhost/hurry.zoperesource.test_bottom')
-  >>> print browser.contents 
+  >>> print browser.contents
   <html>
   <head>
   </head>

Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/ftesting.zcml
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/ftesting.zcml	2010-11-12 15:41:17 UTC (rev 118372)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/ftesting.zcml	2010-11-12 15:44:24 UTC (rev 118373)
@@ -6,26 +6,43 @@
 
   <!-- set up enough of Zope to run the tests -->
 
-  <include package="zope.app.zcmlfiles" />
-  <include package="zope.app.authentication" />
+  <include package="zope.app.publication" file="meta.zcml" />
+  <include package="zope.browserpage" file="meta.zcml" />
+  <include package="zope.component" file="meta.zcml" />
+  <include package="zope.principalregistry" file="meta.zcml" />
+  <include package="zope.security" file="meta.zcml" />
+  <include package="zope.securitypolicy" file="meta.zcml"/>
 
+  <include package="zope.annotation" />
+  <include package="zope.app.appsetup" />
+  <include package="zope.app.publication" />
+  <include package="zope.container" />
+  <include package="zope.principalregistry" />
+  <include package="zope.site" />
+  <include package="zope.traversing.browser" />
+
   <!-- principals -->
+  <securityPolicy
+    component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+  />
 
   <unauthenticatedPrincipal
-      id="zope.anybody"
-      title="Unauthenticated User" />
+    id="zope.anybody"
+    title="Unauthenticated User"
+  />
+  <unauthenticatedGroup
+      id="zope.Anybody"
+      title="Unauthenticated Users"
+      />
+  <everybodyGroup
+      id="zope.Everybody"
+      title="All Users"
+      />
+  <grant
+      permission="zope.View"
+      principal="zope.Everybody"
+      />
 
-  <include package="zope.securitypolicy" file="meta.zcml"/>
-
-  <securityPolicy
-      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
-  <role id="zope.Anonymous" title="Everybody"
-        description="All users have this role implicitly" />
-
-  <grant permission="zope.View"
-         role="zope.Anonymous" />
-
   <include package="hurry.zoperesource"/>
 
   <!-- some pages to use in the tests -->

Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/tests.py
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/tests.py	2010-11-12 15:41:17 UTC (rev 118372)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/tests.py	2010-11-12 15:44:24 UTC (rev 118373)
@@ -1,28 +1,23 @@
-import os
 import unittest
 import doctest
 
-from zope.app.testing.functional import FunctionalDocFileSuite
-from zope.app.testing import functional
+from zope.app.wsgi.testlayer import BrowserLayer
 
-FunctionalLayer = functional.ZCMLLayer(
-    os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
-    __name__, 'FunctionalLayer')
+from hurry.resource.wsgi import InjectMiddleWare
+import hurry.zoperesource.tests
 
 
-def test_suite():
-    optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
-    globs = {}
+class HurryResourceBrowserLayer(BrowserLayer):
+    def setup_middleware(self, app):
+        return InjectMiddleWare(app)
 
-    suite = unittest.TestSuite()
 
-    readme = FunctionalDocFileSuite(
+def test_suite():
+    suite = unittest.TestSuite()
+    readme = doctest.DocFileSuite(
         '../README.txt',
-        optionflags=optionflags,
-        globs=globs)
-
-    readme.layer = FunctionalLayer
-
+        optionflags=doctest.NORMALIZE_WHITESPACE)
+    readme.layer = HurryResourceBrowserLayer(hurry.zoperesource.tests)
     suite.addTest(readme)
 
     return suite



More information about the checkins mailing list