[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Publisher/Browser/tests - testDirectives.py:1.9 testGlobalBrowserMenuServiceDirectives.py:1.2 testIconDirective.py:1.2

Jim Fulton jim@zope.com
Thu, 20 Jun 2002 11:55:29 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv15462/lib/python/Zope/App/Publisher/Browser/tests

Modified Files:
	testDirectives.py testGlobalBrowserMenuServiceDirectives.py 
	testIconDirective.py 
Log Message:
implemented:

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/MergeSecurityIntoZopeNamespace

While I was at it, I couldn't resist implementing a variation of:

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/SecurityPackageReorg

which was a lot more work. 



=== Zope3/lib/python/Zope/App/Publisher/Browser/tests/testDirectives.py 1.8 => 1.9 ===
 import os
 import unittest
-import sys
 
-from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Configuration.xmlconfig import xmlconfig, XMLConfig
 from Zope.Configuration.Exceptions import ConfigurationError
 from Zope.ComponentArchitecture.tests.TestViews import IC, V1, VZMI, R1, RZMI
 from Zope.ComponentArchitecture import getView, queryView, queryResource
@@ -30,13 +29,13 @@
 from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
 
 import Zope.App.Publisher.Browser
-defs_path = os.path.join(
+
+tests_path = os.path.join(
     os.path.split(Zope.App.Publisher.Browser.__file__)[0],
-    'meta.zcml')
+    'tests')
 
 template = """<zopeConfigure
    xmlns='http://namespaces.zope.org/zope'
-   xmlns:security='http://namespaces.zope.org/security'
    xmlns:browser='http://namespaces.zope.org/browser'>
    %s
    </zopeConfigure>"""
@@ -59,7 +58,7 @@
 
     def setUp(self):
         PlacelessSetup.setUp(self)
-        xmlconfig(open(defs_path))
+        XMLConfig('meta.zcml', Zope.App.Publisher.Browser)()
 
         from Zope.ComponentArchitecture.GlobalAdapterService \
              import provideAdapter
@@ -253,9 +252,8 @@
 
 
     def testPageViews(self):
-        self.assertEqual(queryView(ob, 'test', request),
-                         None)
-        test3 = os.path.join(os.path.split(defs_path)[0], 'tests', 'test3.pt')
+        self.assertEqual(queryView(ob, 'test', request), None)
+        test3 = os.path.join(tests_path, 'test3.pt')
 
         xmlconfig(StringIO(template %
             """
@@ -306,9 +304,8 @@
         self.assertEqual(v, 42)
 
     def testNamedViewPageViewsNoDefault(self):
-        self.assertEqual(queryView(ob, 'test', request),
-                         None)
-        test3 = os.path.join(os.path.split(defs_path)[0], 'tests', 'test3.pt')
+        self.assertEqual(queryView(ob, 'test', request), None)
+        test3 = os.path.join(tests_path, 'test3.pt')
 
         xmlconfig(StringIO(template %
             """
@@ -336,9 +333,8 @@
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testNamedViewPageViewsWithDefault(self):
-        self.assertEqual(queryView(ob, 'test', request),
-                         None)
-        test3 = os.path.join(os.path.split(defs_path)[0], 'tests', 'test3.pt')
+        self.assertEqual(queryView(ob, 'test', request), None)
+        test3 = os.path.join(tests_path, 'test3.pt')
 
         xmlconfig(StringIO(template %
             """
@@ -372,13 +368,14 @@
 
         xmlconfig(StringIO(template %
             """
-            <directives namespace="http://namespaces.zope.org/security">
+            <directives namespace="http://namespaces.zope.org/zope">
               <directive name="permission"
                  attributes="id title description"
-                 handler="Zope.App.Security.metaConfigure.definePermission" />
+                 handler="
+             Zope.App.Security.Registries.metaConfigure.definePermission" />
             </directives>
 
-            <security:permission id="XXX" title="xxx" />
+            <permission id="XXX" title="xxx" />
 
             <browser:view
                   factory="Zope.ComponentArchitecture.tests.TestViews.V1"
@@ -444,7 +441,7 @@
 
 
     def testFile(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test.pt')
+        path = os.path.join(tests_path, 'test.pt')
         
         self.assertEqual(queryResource(ob, 'test', request),
                          None)
@@ -463,7 +460,7 @@
 
 
     def testtemplate(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test.pt')
+        path = os.path.join(tests_path, 'test.pt')
         
         self.assertEqual(queryView(ob, 'index.html', request),
                          None)
@@ -481,7 +478,7 @@
         self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
 
     def testtemplateWClass(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test2.pt')
+        path = os.path.join(tests_path, 'test2.pt')
         
         self.assertEqual(queryView(ob, 'index.html', request),
                          None)
@@ -500,20 +497,21 @@
         self.assertEqual(v().strip(), '<html><body><p>42</p></body></html>')
 
     def testProtectedtemplate(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test.pt')
+        path = os.path.join(tests_path, 'test.pt')
         
         self.assertEqual(queryView(ob, 'test', request),
                          None)
 
         xmlconfig(StringIO(template %
             """
-            <directives namespace="http://namespaces.zope.org/security">
+            <directives namespace="http://namespaces.zope.org/zope">
               <directive name="permission"
                  attributes="id title description"
-                 handler="Zope.App.Security.metaConfigure.definePermission" />
+                 handler="
+               Zope.App.Security.Registries.metaConfigure.definePermission" />
             </directives>
 
-            <security:permission id="XXX" title="xxx" />
+            <permission id="XXX" title="xxx" />
 
             <browser:view
                   name="xxx.html"
@@ -547,7 +545,7 @@
         
 
     def testtemplateNoName(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test.pt')
+        path = os.path.join(tests_path, 'test.pt')
         self.assertRaises(
             ConfigurationError,
             xmlconfig,
@@ -561,7 +559,7 @@
             ))
 
     def testtemplateAndPage(self):
-        path = os.path.join(os.path.split(defs_path)[0], 'tests', 'test.pt')
+        path = os.path.join(tests_path, 'test.pt')
         self.assertRaises(
             ConfigurationError,
             xmlconfig,


=== Zope3/lib/python/Zope/App/Publisher/Browser/tests/testGlobalBrowserMenuServiceDirectives.py 1.1 => 1.2 ===
 """
 
-import os
 from StringIO import StringIO
 from unittest import TestCase, TestSuite, main, makeSuite
-from Zope.Configuration.xmlconfig import xmlconfig
+
+from Zope.Configuration.xmlconfig import xmlconfig, XMLConfig
 from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
 from Zope.Publisher.Browser.BrowserRequest import TestRequest
 from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
 
 import Zope.App.Publisher.Browser
-defs_path = os.path.join(
-    os.path.split(Zope.App.Publisher.Browser.__file__)[0],
-    'meta.zcml')
 
 template = """<zopeConfigure
    xmlns='http://namespaces.zope.org/zope'
@@ -41,7 +38,7 @@
 
     def setUp(self):
         PlacelessSetup.setUp(self)
-        xmlconfig(open(defs_path))
+        XMLConfig('meta.zcml', Zope.App.Publisher.Browser)()
         
     def test(self):
         from Zope.App.Publisher.Browser.GlobalBrowserMenuService \


=== Zope3/lib/python/Zope/App/Publisher/Browser/tests/testIconDirective.py 1.1 => 1.2 ===
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
 from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
-from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Configuration.xmlconfig import xmlconfig, XMLConfig
 from Zope.ComponentArchitecture.tests.Request import Request
 from Zope.ComponentArchitecture.tests.TestViews import IC
 from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
 from Zope.ComponentArchitecture import queryView, getView, getResource
 from Zope.Security.Proxy import ProxyFactory
 
-import Zope.App.Publisher.Browser as p
-defs_path = os.path.join(os.path.split(p.__file__)[0], 'meta.zcml')
+import Zope.App.Publisher.Browser
 
 template = """<zopeConfigure
    xmlns='http://namespaces.zope.org/zope'
@@ -52,13 +51,14 @@
 
     def setUp(self):
         PlacelessSetup.setUp(self)
-        xmlconfig(open(defs_path))
+        XMLConfig('meta.zcml', Zope.App.Publisher.Browser)()
 
     def test(self):
         self.assertEqual(queryView(ob, 'zmi_icon', request), None)
 
-        package_directory = os.path.split(defs_path)[0]
-        path = os.path.join(package_directory, "tests", 'test.gif')
+        import Zope.App.Publisher.Browser.tests as p
+        path = os.path.split(p.__file__)[0]
+        path = os.path.join(path, 'test.gif')
         
         xmlconfig(StringIO(template % (
             """