[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_directives.py:1.8.2.1 test_globalbrowsermenuservice.py:1.4.2.1

Sidnei da Silva sidnei@x3ng.com.br
Tue, 11 Feb 2003 09:41:56 -0500


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv18615/src/zope/app/publisher/browser/tests

Modified Files:
      Tag: paris-copypasterename-branch
	test_directives.py test_globalbrowsermenuservice.py 
Log Message:
Updating from HEAD to make sure everything still works before merging

=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.8 => 1.8.2.1 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.8	Tue Dec 31 13:26:59 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py	Tue Feb 11 09:41:25 2003
@@ -21,6 +21,7 @@
 from zope.component.tests.views import IC, V1, VZMI, R1, RZMI
 from zope.component import getView, queryView, queryResource
 from zope.component import getDefaultViewName, getResource
+from zope.component.servicenames import Permissions
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.security.proxy import ProxyFactory
 from zope.proxy.introspection import removeAllProxies
@@ -65,6 +66,17 @@
 
 ob = Ob()
 
+class NCV(object):
+    "non callable view"
+    
+    def __init__(self, context, request):
+        pass
+
+class CV(NCV):
+    "callable view"
+    def __call__(self):
+        pass
+
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
@@ -330,6 +342,42 @@
         self.assertEqual(v(), 'done')
 
 
+    def testNamedViewNoPagesForCallable(self):
+        self.assertEqual(queryView(ob, 'test', request), None)
+
+        xmlconfig(StringIO(template %
+            """
+            <browser:view
+                  name="test"
+                  class="zope.app.publisher.browser.tests.test_directives.CV"
+                  for="zope.component.tests.views.IC"
+                  permission="zope.Public"
+                  />
+            """
+            ))
+
+        view = getView(ob, 'test', request)
+        view = removeAllProxies(view)
+        self.assertEqual(view.browserDefault(request), (view, ()))
+
+    def testNamedViewNoPagesForNonCallable(self):
+        self.assertEqual(queryView(ob, 'test', request), None)
+
+        xmlconfig(StringIO(template %
+            """
+            <browser:view
+                  name="test"
+                  class="zope.app.publisher.browser.tests.test_directives.NCV"
+                  for="zope.component.tests.views.IC"
+                  permission="zope.Public"
+                  />
+            """
+            ))
+
+        view = getView(ob, 'test', request)
+        view = removeAllProxies(view)
+        self.assertEqual(getattr(view, 'browserDefault', None), None)
+
     def testNamedViewPageViewsNoDefault(self):
         self.assertEqual(queryView(ob, 'test', request), None)
         test3 = os.path.join(tests_path, 'test3.pt')
@@ -403,8 +451,8 @@
 
     def testProtectedPageViews(self):
 
-        serviceManager.defineService('Permissions', IPermissionService)
-        serviceManager.provideService('Permissions', permissionRegistry)
+        serviceManager.defineService(Permissions, IPermissionService)
+        serviceManager.provideService(Permissions, permissionRegistry)
         permissionRegistry.definePermission('p', 'P')
 
 
@@ -601,8 +649,8 @@
 
     def testProtectedtemplate(self):
 
-        serviceManager.defineService('Permissions', IPermissionService)
-        serviceManager.provideService('Permissions', permissionRegistry)
+        serviceManager.defineService(Permissions, IPermissionService)
+        serviceManager.provideService(Permissions, permissionRegistry)
         
         path = os.path.join(tests_path, 'test.pt')
 


=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py 1.4 => 1.4.2.1 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py:1.4	Mon Dec 30 22:35:09 2002
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py	Tue Feb 11 09:41:25 2003
@@ -26,6 +26,7 @@
 from zope.app.tests.placelesssetup import PlacelessSetup
 
 from zope.component.service import serviceManager
+from zope.component.servicenames import Permissions
 from zope.app.security.registries.permissionregistry import permissionRegistry
 from zope.app.interfaces.security import IPermissionService
 from zope.security.management import newSecurityManager
@@ -89,8 +90,8 @@
         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)
+        serviceManager.defineService(Permissions, IPermissionService)
+        serviceManager.provideService(Permissions, permissionRegistry)
         permissionRegistry.definePermission('p', 'P')
         
         r = self.__reg()