[Zope3-checkins] CVS: Zope3/src/zope/app/contentdirective/tests - modulehookup.py:1.1.2.1 test_directives.py:1.1.2.2 test_factory.py:1.1.2.2 test_requirepermissions.py:1.1.2.2 test_modulehookup.py:NONE

Guido van Rossum guido@python.org
Mon, 23 Dec 2002 18:49:20 -0500


Update of /cvs-repository/Zope3/src/zope/app/contentdirective/tests
In directory cvs.zope.org:/tmp/cvs-serv2099/tests

Modified Files:
      Tag: NameGeddon-branch
	test_directives.py test_factory.py test_requirepermissions.py 
Added Files:
      Tag: NameGeddon-branch
	modulehookup.py 
Removed Files:
      Tag: NameGeddon-branch
	test_modulehookup.py 
Log Message:
Make it work.

=== Added File Zope3/src/zope/app/contentdirective/tests/modulehookup.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""Preliminaries to hookup a test suite with the external TestModule.

This is necessary because the test framework interferes with seeing changes in
the running modules via the module namespace.  This enables having some
subject classes, instances, permissions, etc, that don't live in the test
modules, themselves."""

from zope.interface import Interface
from zope.schema import Text

PREFIX = "zope.app.security.tests.module."
import zope.app.security.tests.module as module
module.test_class = None
class I(Interface):
    def m1():
        pass
    def m2():
        pass

class I2(I):
    def m4():
        pass
    

class S(Interface):
    foo = Text()
    bar = Text()
    

module.I = I
module.I2 = I2
module.S = S

template_bracket = """<zopeConfigure
   xmlns="http://namespaces.zope.org/zope">
   %s
</zopeConfigure>"""


=== Zope3/src/zope/app/contentdirective/tests/test_directives.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/contentdirective/tests/test_directives.py:1.1.2.1	Mon Dec 23 14:31:32 2002
+++ Zope3/src/zope/app/contentdirective/tests/test_directives.py	Mon Dec 23 18:49:19 2002
@@ -26,9 +26,8 @@
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.security.securitymanagement import newSecurityManager, system_user
 import zope.configuration
-import Zope.App.ComponentArchitecture
-import Zope.App.Security
-import Zope.App.ContentDirective
+import zope.app.security
+import zope.app.contentdirective
 from zope.app.security.exceptions import UndefinedPermissionError
 
 # explicitly import ExampleClass and IExample using full paths
@@ -47,9 +46,9 @@
     def setUp(self):
         PlacelessSetup.setUp(self)
         newSecurityManager(system_user)
-        XMLConfig('metameta.zcml', Zope.Configuration)()
-        XMLConfig('meta.zcml', Zope.App.ContentDirective)()
-        XMLConfig('meta.zcml', Zope.App.Security)()
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('meta.zcml', zope.app.contentdirective)()
+        XMLConfig('meta.zcml', zope.app.security)()
         
         try:
             del ExampleClass.__implements__
@@ -58,7 +57,7 @@
             
     def testEmptyDirective(self):
         f = configfile("""
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
 </content>
                        """)
         xmlconfig(f)
@@ -66,8 +65,8 @@
             
     def testImplements(self):
         f = configfile("""
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
-  <implements interface="Zope.App.ContentDirective.tests.ExampleClass.IExample" />
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
+  <implements interface="zope.app.contentdirective.tests.exampleclass.IExample" />
 </content>
                        """)
         xmlconfig(f)
@@ -77,7 +76,7 @@
     def testRequire(self):
         f = configfile("""
 <permission id="Zope.View" title="Zope view permission" />
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <require permission="Zope.View"
                       attributes="anAttribute anotherAttribute" />
 </content>
@@ -86,7 +85,7 @@
 
     def testAllow(self):
         f = configfile("""
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <allow attributes="anAttribute anotherAttribute" />
 </content>
                        """)
@@ -94,8 +93,8 @@
         
     def testMimic(self):
         f = configfile("""
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
-    <require like_class="Zope.App.ContentDirective.tests.ExampleClass." />
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
+    <require like_class="zope.app.contentdirective.tests.exampleclass.ExampleClass" />
 </content>
                        """)
         xmlconfig(f)
@@ -105,15 +104,15 @@
     def setUp(self):
         PlacelessSetup.setUp(self)
         newSecurityManager(system_user)
-        XMLConfig('metameta.zcml', Zope.Configuration)()
-        XMLConfig('meta.zcml', Zope.App.ContentDirective)()
-        XMLConfig('meta.zcml', Zope.App.Security)()
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('meta.zcml', zope.app.contentdirective)()
+        XMLConfig('meta.zcml', zope.app.security)()
 
     def testFactory(self):
         f = configfile("""
 <permission id="Zope.Foo" title="Zope Foo Permission" />
 
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <factory 
       id="Example" 
       permission="Zope.Foo"
@@ -130,7 +129,7 @@
         f = configfile("""
 <permission id="Zope.Foo" title="Zope Foo Permission" />
 
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <factory 
       id="Example" 
       permission="UndefinedPermission"


=== Zope3/src/zope/app/contentdirective/tests/test_factory.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/contentdirective/tests/test_factory.py:1.1.2.1	Mon Dec 23 14:31:32 2002
+++ Zope3/src/zope/app/contentdirective/tests/test_factory.py	Mon Dec 23 18:49:19 2002
@@ -24,10 +24,10 @@
 from zope.security.securitymanagement import newSecurityManager, system_user
 
 import zope.configuration
-import Zope.App.Security
+import zope.app.security
 from zope.app.security.exceptions import UndefinedPermissionError
 
-import Zope.App.ContentDirective
+import zope.app.contentdirective
 from zope.app.contentdirective.tests.exampleclass \
     import ExampleClass, IExample, IExampleContainer
 
@@ -42,9 +42,9 @@
     def setUp(self):
         PlacelessSetup.setUp(self)
         newSecurityManager(system_user)
-        XMLConfig('metameta.zcml', Zope.Configuration)()
-        XMLConfig('meta.zcml', Zope.App.ContentDirective)()
-        XMLConfig('meta.zcml', Zope.App.Security)()
+        XMLConfig('metameta.zcml', zope.configuration)()
+        XMLConfig('meta.zcml', zope.app.contentdirective)()
+        XMLConfig('meta.zcml', zope.app.security)()
 
 
     def testFactory(self):
@@ -52,7 +52,7 @@
         from zope.proxy.introspection import removeAllProxies
         f = configfile("""
 <permission id="Zope.Foo" title="Zope Foo Permission" />
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <factory 
       id="Example" 
       permission="Zope.Foo"
@@ -71,7 +71,7 @@
         from zope.proxy.introspection import removeAllProxies
         f = configfile("""
 <permission id="Zope.Foo" title="Zope Foo Permission" />
-<content class="Zope.App.ContentDirective.tests.ExampleClass.">
+<content class="zope.app.contentdirective.tests.exampleclass.ExampleClass">
     <factory 
       permission="Zope.Foo"
       title="Example content"
@@ -81,7 +81,7 @@
                        """)
         xmlconfig(f)
         obj = getService(None, "Factories").createObject(
-            'Zope.App.ContentDirective.tests.ExampleClass.')
+            'zope.app.contentdirective.tests.exampleclass.ExampleClass')
         obj = removeAllProxies(obj)
         self.failUnless(isinstance(obj, ExampleClass))
 


=== Zope3/src/zope/app/contentdirective/tests/test_requirepermissions.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/contentdirective/tests/test_requirepermissions.py:1.1.2.1	Mon Dec 23 14:31:32 2002
+++ Zope3/src/zope/app/contentdirective/tests/test_requirepermissions.py	Mon Dec 23 18:49:19 2002
@@ -17,27 +17,25 @@
 from cStringIO import StringIO
 
 import zope.configuration
-import Zope.App.Security
-from Zope.App.Security import protectClass
+import zope.app.security
 from zope.app.security.exceptions import UndefinedPermissionError
 from zope.security.checker import selectChecker
 from zope.exceptions import Forbidden
 
-
 # So we can use config parser to exercise protectClass stuff.
 from zope.configuration.xmlconfig import xmlconfig, ZopeXMLConfigurationError
 from zope.configuration.xmlconfig import XMLConfig
 
-from zope.app.contentdirective.tests.test_modulehookup import * # XXX I hate this!
+from zope.app.contentdirective.tests.modulehookup import * # XXX I hate this!
 
 from zope.testing.cleanup import CleanUp # Base class w registry cleanup
 
-import Zope.App.ContentDirective
+import zope.app.contentdirective
 
 def defineDirectives():
-    XMLConfig('metameta.zcml', Zope.Configuration)()
-    XMLConfig('meta.zcml', Zope.App.ContentDirective)()
-    XMLConfig('meta.zcml', Zope.App.Security)()
+    XMLConfig('metameta.zcml', zope.configuration)()
+    XMLConfig('meta.zcml', zope.app.contentdirective)()
+    XMLConfig('meta.zcml', zope.app.security)()
     xmlconfig(StringIO("""<zopeConfigure
         xmlns='http://namespaces.zope.org/zope' >
        <permission id="extravagant" title="extravagant" />
@@ -64,14 +62,14 @@
                 return "m3"
             def m4(self):
                 return "m4"
-        TestModule.test_base = B
-        TestModule.test_class = C
-        TestModule.test_instance = C()
+        module.test_base = B
+        module.test_class = C
+        module.test_instance = C()
         self.assertState()
 
     def tearDown(self):
         CleanUp.tearDown(self)
-        TestModule.test_class = None
+        module.test_class = None
 
     def assertState(self, m1P=NOTSET, m2P=NOTSET, m3P=NOTSET):
         "Verify that class, instance, and methods have expected permissions."
@@ -79,7 +77,7 @@
         from zope.security.checker import selectChecker
         from zope.exceptions import Forbidden
 
-        checker = selectChecker(TestModule.test_instance)
+        checker = selectChecker(module.test_instance)
         self.assertEqual(checker.permission_id('m1'), (m1P or None))
         self.assertEqual(checker.permission_id('m2'), (m2P or None))
         self.assertEqual(checker.permission_id('m3'), (m3P or None))
@@ -106,7 +104,7 @@
         from zope.security.checker import selectChecker
         from zope.exceptions import Forbidden
 
-        checker = selectChecker(TestModule.test_instance)
+        checker = selectChecker(module.test_instance)
         self.assertEqual(checker.setattr_permission_id('m1'), (m1P or None))
         self.assertEqual(checker.setattr_permission_id('m2'), (m2P or None))
         self.assertEqual(checker.setattr_permission_id('m3'), (m3P or None))
@@ -122,7 +120,7 @@
                           </content>"""
                        % (PREFIX+"test_class", P1))
         apply_declaration(template_bracket % declaration)
-        checker = selectChecker(TestModule.test_instance)
+        checker = selectChecker(module.test_instance)
         self.assertEqual(checker.setattr_permission_id('m1'), P1)
         self.assertEqual(checker.setattr_permission_id('m2'), None)
         self.assertEqual(checker.setattr_permission_id('m3'), P1)
@@ -135,7 +133,7 @@
                           </content>"""
                        % (PREFIX+"test_class", P1, PREFIX+"S"))
         apply_declaration(template_bracket % declaration)
-        checker = selectChecker(TestModule.test_instance)
+        checker = selectChecker(module.test_instance)
         self.assertEqual(checker.setattr_permission_id('m1'), None)
         self.assertEqual(checker.setattr_permission_id('m2'), None)
         self.assertEqual(checker.setattr_permission_id('m3'), None)

=== Removed File Zope3/src/zope/app/contentdirective/tests/test_modulehookup.py ===