[Checkins] SVN: hurry.zoperesource/branches/janjaapdriessen-wsgi/ Tests, update changes
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Mon Nov 15 11:46:23 EST 2010
Log message for revision 118414:
Tests, update changes
Changed:
U hurry.zoperesource/branches/janjaapdriessen-wsgi/CHANGES.txt
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
U hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/view.py
-=-
Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/CHANGES.txt
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/CHANGES.txt 2010-11-15 16:46:04 UTC (rev 118413)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/CHANGES.txt 2010-11-15 16:46:23 UTC (rev 118414)
@@ -12,6 +12,10 @@
- Replaced zope.app.testing/zope.app.zcmlfiles test setup with zope.app.wsgi.
+- Register a custom DirectoryResource and DirectoryResourceFactory in order
+ to mark resources with a marker interface and render URLs that know about
+ the hurry.resource.publisher.
+
0.7 (2010-10-01)
================
Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt 2010-11-15 16:46:04 UTC (rev 118413)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/README.txt 2010-11-15 16:46:23 UTC (rev 118414)
@@ -26,7 +26,7 @@
>>> print browser.contents
<html>
<head>
- <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
+ <script type="text/javascript" src="http://localhost/media/foo/hash:2258902149/a.js"></script>
<BLANKLINE>
</head>
<body>
@@ -41,8 +41,8 @@
>>> print browser.contents
<html>
<head>
- <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
- <script type="text/javascript" src="http://localhost/@@/foo/b.js"></script>
+ <script type="text/javascript" src="http://localhost/media/foo/hash:2258902149/a.js"></script>
+ <script type="text/javascript" src="http://localhost/media/foo/hash:2258902149/b.js"></script>
<BLANKLINE>
</head>
<body>
@@ -60,6 +60,24 @@
</head>
<body>
<p>the widget HTML itself</p>
- <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
- <script type="text/javascript" src="http://localhost/@@/foo/b.js"></script></body>
+ <script type="text/javascript" src="http://localhost/media/foo/hash:2258902149/a.js"></script>
+ <script type="text/javascript" src="http://localhost/media/foo/hash:2258902149/b.js"></script></body>
</html>
+
+In-template resources
+---------------------
+
+Hurry.zoperesource also provides support for rendering URLs to in-template
+resources::
+
+ >>> browser.open('http://localhost/hurry.zoperesource.test_inline_resource')
+ >>> print browser.contents
+ <html>
+ <head>
+ </head>
+ <body>
+ <img src="http://localhost/media/foo/hash:2258902149/evencaveman.jpg"/>
+ </body>
+ </html>
+
+
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-15 16:46:04 UTC (rev 118413)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/ftesting.zcml 2010-11-15 16:46:23 UTC (rev 118414)
@@ -71,4 +71,12 @@
class=".view.TestBottom"
/>
+ <browser:page
+ for="zope.interface.Interface"
+ name="hurry.zoperesource.test_inline_resource"
+ permission="zope.Public"
+ template="test_inline_resource.pt"
+ class=".view.TestInlineResource"
+ />
+
</configure>
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-15 16:46:04 UTC (rev 118413)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/tests.py 2010-11-15 16:46:23 UTC (rev 118414)
@@ -1,23 +1,37 @@
import unittest
import doctest
+from zope.interface import Interface
+from zope.component import getGlobalSiteManager
from zope.app.wsgi.testlayer import BrowserLayer
+from zope.publisher.interfaces.browser import IBrowserRequest
from hurry.resource.wsgi import InjectMiddleWare
+from hurry.zoperesource.zcml import create_resource_factory
+from hurry.zoperesource.tests.view import foo
import hurry.zoperesource.tests
class HurryResourceBrowserLayer(BrowserLayer):
+
+ def testSetUp(self):
+ super(HurryResourceBrowserLayer, self).testSetUp()
+
+ # Because it is difficult to dynamically register a entry_point in
+ # tests, we do the setup by hand:
+ resource_factory = create_resource_factory(foo)
+ gsm = getGlobalSiteManager()
+ gsm.registerAdapter(
+ resource_factory, (IBrowserRequest,), Interface, foo.name)
+
+
def setup_middleware(self, app):
- return InjectMiddleWare(app)
+ return InjectMiddleWare(app, publisher_prefix='/media')
def test_suite():
- suite = unittest.TestSuite()
readme = doctest.DocFileSuite(
'../README.txt',
optionflags=doctest.NORMALIZE_WHITESPACE)
readme.layer = HurryResourceBrowserLayer(hurry.zoperesource.tests)
- suite.addTest(readme)
-
- return suite
+ return unittest.TestSuite([readme])
Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/view.py
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/view.py 2010-11-15 16:46:04 UTC (rev 118413)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/tests/view.py 2010-11-15 16:46:23 UTC (rev 118414)
@@ -25,3 +25,7 @@
b.need()
bottom(force=True)
return "the widget HTML itself"
+
+
+class TestInlineResource(object):
+ pass
More information about the checkins
mailing list