[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests -
test_directives.py:1.25
Jim Fulton
cvs-admin at zope.org
Fri Nov 21 12:10:38 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv30789/src/zope/app/publisher/browser/tests
Modified Files:
test_directives.py
Log Message:
Changed to use the new ztapi module, which provides handy functions
for setting up adapters and views for tests. This is needed because
there are no-longer global adapter and view services sitting around as
module globals.
Also changed to use the browser test request.
=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.24 => 1.25 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.24 Mon Sep 22 18:37:26 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py Fri Nov 21 12:10:36 2003
@@ -30,11 +30,8 @@
from zope.app.publisher.browser.globalbrowsermenuservice import \
globalBrowserMenuService
-from zope.component.tests.request import Request
from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.browser import IBrowserPresentation
-
from zope.app.publisher.browser.i18nfileresource import I18nFileResource
import zope.app.publisher.browser
@@ -59,7 +56,8 @@
%s
</configure>"""
-request = Request(IBrowserPresentation)
+
+request = TestRequest()
class VT(V1, object):
def publishTraverse(self, request, name):
@@ -98,11 +96,11 @@
PlacelessSetup.setUp(self)
XMLConfig('meta.zcml', zope.app.publisher.browser)()
- from zope.component.adapter import provideAdapter
+ from zope.app.tests import ztapi
from zope.app.traversing.adapters import DefaultTraversable
from zope.app.interfaces.traversing import ITraversable
- provideAdapter(None, ITraversable, DefaultTraversable)
+ ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
def testPage(self):
self.assertEqual(queryView(ob, 'test', request),
@@ -142,7 +140,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -190,7 +189,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -215,7 +215,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -261,7 +262,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -287,7 +289,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -314,7 +317,8 @@
""" % testusage
)))
- menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
+ menuItem = globalBrowserMenuService.getFirstMenuItem(
+ 'test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
self.assertEqual(menuItem["action"], "@@test")
v = queryView(ob, 'test', request)
@@ -341,6 +345,7 @@
xmlconfig(StringIO(template % (
"""
+ <browser:layer name="zmi" />
<browser:skin name="zmi" layers="zmi default" />
<browser:page name="test"
class="zope.component.tests.views.VZMI"
@@ -360,7 +365,7 @@
v = queryView(ob, 'test', request)
self.assert_(issubclass(v.__class__, V1))
- v = queryView(ob, 'test', Request(IBrowserPresentation, 'zmi'))
+ v = queryView(ob, 'test', TestRequest(skin='zmi'))
self.assert_(issubclass(v.__class__, VZMI))
def testI18nResource(self):
@@ -763,6 +768,7 @@
xmlconfig(StringIO(template %
"""
+ <browser:layer name="layer" />
<browser:skin name="skinny" layers="layer default" />
<browser:pages
for="*"
@@ -786,8 +792,7 @@
v = getView(ob, 'index.html', request)
self.assertEqual(v(), 'V1 here')
- v = getView(ob, 'index.html',
- Request(IBrowserPresentation, "skinny"))
+ v = getView(ob, 'index.html', TestRequest(skin="skinny"))
self.assertEqual(v(), 'done')
def testFile(self):
@@ -826,6 +831,7 @@
xmlconfig(StringIO(template % (
"""
+ <browser:layer name="zmi" />
<browser:skin name="zmi" layers="zmi default" />
<browser:resource name="test" file="%s"
layer="zmi" />
@@ -834,7 +840,7 @@
self.assertEqual(queryResource(ob, 'test', request), None)
- r = getResource(ob, 'test', Request(IBrowserPresentation, 'zmi'))
+ r = getResource(ob, 'test', TestRequest(skin='zmi'))
r = removeAllProxies(r)
self.assertEqual(r._testData(), open(path, 'rb').read())
More information about the Zope3-Checkins
mailing list