[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests -
test_directives.py:1.31 test_globalbrowsermenuservice.py:1.16
test_icondirective.py:1.17
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:06:30 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/publisher/browser/tests
Modified Files:
test_directives.py test_globalbrowsermenuservice.py
test_icondirective.py
Log Message:
Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.
=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.30 => 1.31 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.30 Fri Mar 5 17:09:14 2004
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py Mon Mar 8 07:05:59 2004
@@ -11,6 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""'browser' namespace directive tests
+
+$Id$
+"""
import os
import unittest
@@ -23,7 +27,6 @@
from zope.app.component.tests.views import IC, V1, VZMI, R1, IV
from zope.component import getView, queryView, queryResource
from zope.component import getDefaultViewName, getResource
-from zope.app.services.servicenames import Permissions
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.security.proxy import ProxyFactory
from zope.proxy import removeAllProxies
@@ -36,15 +39,15 @@
import zope.app.publisher.browser
from zope.component.service import serviceManager
-from zope.app.interfaces.security import IPermissionService
-from zope.app.security.registries.permissionregistry import permissionRegistry
-
-from zope.component.service import serviceManager
-from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.app.interfaces.security import IPermissionService
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.app import zapi
+from zope.app.tests import ztapi
+from zope.app.traversing.adapters import DefaultTraversable
+from zope.app.interfaces.traversing import ITraversable
+
+from zope.app.security.permission import Permission
+from zope.app.security.interfaces import IPermission
tests_path = os.path.join(
os.path.split(zope.app.publisher.browser.__file__)[0],
@@ -98,10 +101,6 @@
XMLConfig('meta.zcml', zope.app.publisher.browser)()
- from zope.app.tests import ztapi
- from zope.app.traversing.adapters import DefaultTraversable
- from zope.app.interfaces.traversing import ITraversable
-
ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
ps = zapi.getService(None, zapi.servicenames.Presentation)
@@ -691,11 +690,7 @@
self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
def testProtectedPageViews(self):
-
- serviceManager.defineService(Permissions, IPermissionService)
- serviceManager.provideService(Permissions, permissionRegistry)
- permissionRegistry.definePermission('p', 'P')
-
+ ztapi.provideUtility(IPermission, Permission('p', 'P'), 'p')
self.assertEqual(queryView(ob, 'test', request),
None)
@@ -706,7 +701,7 @@
<directive name="permission"
attributes="id title description"
handler="
- zope.app.security.registries.metaconfigure.definePermission" />
+ zope.app.security.metaconfigure.definePermission" />
</directives>
<permission id="zope.TestPermission" title="Test permission" />
@@ -740,7 +735,7 @@
<directive name="permission"
attributes="id title description"
handler="
- zope.app.security.registries.metaconfigure.definePermission" />
+ zope.app.security.metaconfigure.definePermission" />
</directives>
<permission id="zope.TestPermission" title="Test permission" />
@@ -891,9 +886,6 @@
def testProtectedtemplate(self):
- serviceManager.defineService(Permissions, IPermissionService)
- serviceManager.provideService(Permissions, permissionRegistry)
-
path = os.path.join(tests_path, 'testfiles', 'test.pt')
self.assertEqual(queryView(ob, 'test', request),
@@ -905,7 +897,7 @@
<directive name="permission"
attributes="id title description"
handler="
- zope.app.security.registries.metaconfigure.definePermission" />
+ zope.app.security.metaconfigure.definePermission" />
</directives>
<permission id="zope.TestPermission" title="Test permission" />
=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py:1.15 Sun Dec 7 05:04:53 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py Mon Mar 8 07:05:59 2004
@@ -16,19 +16,19 @@
$Id$
"""
import unittest
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.interfaces.security import IPermissionService
-from zope.app.publisher.browser.globalbrowsermenuservice import \
- GlobalBrowserMenuService
-from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.app.services.servicenames import Permissions
-from zope.component.service import serviceManager
from zope.exceptions import Forbidden, Unauthorized, DuplicationError
from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.security.management import newSecurityManager, system_user
+
from zope.app import zapi
+from zope.app.tests import ztapi
+from zope.app.security.interfaces import IPermission
+from zope.app.security.permission import Permission
+from zope.app.publisher.browser.globalbrowsermenuservice import \
+ GlobalBrowserMenuService
+from zope.app.tests.placelesssetup import PlacelessSetup
class I1(Interface): pass
class I11(I1): pass
@@ -88,9 +88,7 @@
self.assertEqual(list(menu), [d(5), d(6), d(3), d(2), d(1)])
def test_w_permission(self):
- serviceManager.defineService(Permissions, IPermissionService)
- serviceManager.provideService(Permissions, permissionRegistry)
- permissionRegistry.definePermission('p', 'P')
+ ztapi.provideUtility(IPermission, Permission('p', 'P'), 'p')
r = self.__reg()
r.menu('test_id', 'test menu')
=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py:1.16 Wed Dec 17 05:06:42 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py Mon Mar 8 07:05:59 2004
@@ -11,9 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Test Icon-Directive
-Revision information:
$Id$
"""
import os
@@ -31,8 +30,9 @@
from zope.interface import implements
from zope.app.interfaces.services.service import ISite
from zope.app.interfaces.traversing import IContainmentRoot
-from zope.security.checker import ProxyFactory
+from zope.security.checker import ProxyFactory, CheckerPublic
+from zope.app.tests import ztapi
import zope.app.publisher.browser
template = """<configure
More information about the Zope3-Checkins
mailing list