[Checkins] SVN: five.grok/trunk/src/five/grok/ Fix DirectoryResource tests so they test the Zope 2 implementation.
Sylvain Viollon
sylvain at infrae.com
Sat Nov 15 11:47:29 EST 2008
Log message for revision 92982:
Fix DirectoryResource tests so they test the Zope 2 implementation.
Changed:
U five.grok/trunk/src/five/grok/__init__.py
U five.grok/trunk/src/five/grok/ftests/directoryresource/dirresource.py
U five.grok/trunk/src/five/grok/ftests/directoryresource/fixture/resource.py
U five.grok/trunk/src/five/grok/ftests/test_grok_functional.py
U five.grok/trunk/src/five/grok/ftests/view/resource.py
-=-
Modified: five.grok/trunk/src/five/grok/__init__.py
===================================================================
--- five.grok/trunk/src/five/grok/__init__.py 2008-11-15 16:32:05 UTC (rev 92981)
+++ five.grok/trunk/src/five/grok/__init__.py 2008-11-15 16:47:29 UTC (rev 92982)
@@ -22,6 +22,10 @@
from five.grok.components import EditForm, DisplayForm
from five.grok.components import ViewletManager, Viewlet
+# Temporary import explicitly path from grokcore.view (it was missing
+# in its API interface)
+from grokcore.view import path
+
# Override the one from grokcore.view so that we get Zope 2 semantics
from five.grok.components import ZopeTwoPageTemplate as PageTemplate
from five.grok.components import ZopeTwoPageTemplateFile as PageTemplateFile
Modified: five.grok/trunk/src/five/grok/ftests/directoryresource/dirresource.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/directoryresource/dirresource.py 2008-11-15 16:32:05 UTC (rev 92981)
+++ five.grok/trunk/src/five/grok/ftests/directoryresource/dirresource.py 2008-11-15 16:47:29 UTC (rev 92982)
@@ -3,12 +3,12 @@
through the dotted name of the module in which the directoryresource is
defined::
- >>> from zope.testbrowser.testing import Browser
+ >>> from Products.Five.testbrowser import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open(
- ... 'http://localhost/@@/'
- ... 'grokcore.view.ftests.directoryresource.fixture.resource/file.txt')
+ ... 'http://localhost/'
+ ... '++resource++five.grok.ftests.directoryresource.fixture.resource/file.txt')
>>> print browser.contents
Foo resource file's content.
@@ -16,51 +16,51 @@
skins)::
>>> browser.open(
- ... 'http://localhost/++skin++another/@@/'
- ... 'grokcore.view.ftests.directoryresource.fixture.resource/file.txt')
+ ... 'http://localhost/++skin++another/'
+ ... '++resource++five.grok.ftests.directoryresource.fixture.resource/file.txt')
>>> print browser.contents
Anotherfoo resource file's content.
This resource is only available on the particular layer::
>>> browser.open(
- ... 'http://localhost/++skin++another/@@/'
- ... 'grokcore.view.ftests.directoryresource.fixture.resource/'
+ ... 'http://localhost/++skin++another/'
+ ... '++resource++five.grok.ftests.directoryresource.fixture.resource/'
... 'anotherfile.txt')
>>> print browser.contents
Anotherfoo resource anotherfile's content.
>>> browser.handleErrors = True
>>> browser.open(
- ... 'http://localhost/@@/'
- ... 'grokcore.view.ftests.directoryresource.fixture.resource/'
+ ... 'http://localhost/'
+ ... '++resource++five.grok.ftests.directoryresource.fixture.resource/'
... 'anotherfile.txt')
Traceback (most recent call last):
...
- httperror_seek_wrapper: HTTP Error 404: Not Found
+ HTTPError: HTTP Error 404: Not Found
Directoryresources can be registered under an explicit name::
>>> browser.handleErrors = False
- >>> browser.open('http://localhost/@@/fropple/file.txt')
+ >>> browser.open('http://localhost/++resource++fropple/file.txt')
>>> print browser.contents
Bar resource file's content.
Subdirectories are published as directoryresources recusively::
- >>> browser.open('http://localhost/@@/fropple/baz/file.txt')
+ >>> browser.open('http://localhost/++resource++fropple/baz/file.txt')
>>> print browser.contents
Baz resource file's content.
A relative path to a directory with resources::
- >>> browser.open('http://localhost/@@/frepple/file.txt')
+ >>> browser.open('http://localhost/++resource++frepple/file.txt')
>>> print browser.contents
Baz resource file's content.
An absolute path to a directory with resources::
- >>> browser.open('http://localhost/@@/frupple/file.txt')
+ >>> browser.open('http://localhost/++resource++frupple/file.txt')
>>> print browser.contents
Baz resource file's content.
Modified: five.grok/trunk/src/five/grok/ftests/directoryresource/fixture/resource.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/directoryresource/fixture/resource.py 2008-11-15 16:32:05 UTC (rev 92981)
+++ five.grok/trunk/src/five/grok/ftests/directoryresource/fixture/resource.py 2008-11-15 16:47:29 UTC (rev 92982)
@@ -1,26 +1,26 @@
import os
-import grokcore.view
+from five import grok
-class DirectoryResourceFoo(grokcore.view.DirectoryResource):
- grokcore.view.path('foo')
+class DirectoryResourceFoo(grok.DirectoryResource):
+ grok.path('foo')
-class IAnotherLayer(grokcore.view.IDefaultBrowserLayer):
- grokcore.view.skin('another')
+class IAnotherLayer(grok.IDefaultBrowserLayer):
+ grok.skin('another')
-class DirectoryResourceFooOnLayer(grokcore.view.DirectoryResource):
- grokcore.view.layer(IAnotherLayer)
- grokcore.view.path('anotherfoo')
+class DirectoryResourceFooOnLayer(grok.DirectoryResource):
+ grok.layer(IAnotherLayer)
+ grok.path('anotherfoo')
-class DirectoryResourceBarWithName(grokcore.view.DirectoryResource):
- grokcore.view.name('fropple')
- grokcore.view.path('bar')
+class DirectoryResourceBarWithName(grok.DirectoryResource):
+ grok.name('fropple')
+ grok.path('bar')
-class DirectoryResourceBazInsubdirWithName(grokcore.view.DirectoryResource):
- grokcore.view.name('frepple')
- grokcore.view.path('bar/baz')
+class DirectoryResourceBazInsubdirWithName(grok.DirectoryResource):
+ grok.name('frepple')
+ grok.path('bar/baz')
absolute_path = os.path.join(os.path.dirname(__file__), 'bar', 'baz')
-class DirectoryResourceQuxWithNameAbsolutePath(grokcore.view.DirectoryResource):
- grokcore.view.name('frupple')
- grokcore.view.path(absolute_path)
+class DirectoryResourceQuxWithNameAbsolutePath(grok.DirectoryResource):
+ grok.name('frupple')
+ grok.path(absolute_path)
Modified: five.grok/trunk/src/five/grok/ftests/test_grok_functional.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/test_grok_functional.py 2008-11-15 16:32:05 UTC (rev 92981)
+++ five.grok/trunk/src/five/grok/ftests/test_grok_functional.py 2008-11-15 16:47:29 UTC (rev 92982)
@@ -58,7 +58,7 @@
def test_suite():
suite = unittest.TestSuite()
- for name in ['view', 'viewlet','form']:
+ for name in ['directoryresource', 'view', 'viewlet','form']:
suite.addTest(suiteFromPackage(name))
return suite
Modified: five.grok/trunk/src/five/grok/ftests/view/resource.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/view/resource.py 2008-11-15 16:32:05 UTC (rev 92981)
+++ five.grok/trunk/src/five/grok/ftests/view/resource.py 2008-11-15 16:47:29 UTC (rev 92982)
@@ -36,7 +36,6 @@
</body>
</html>
-
"""
from five import grok
More information about the Checkins
mailing list