[Zope-CVS] CVS: Products/CompositePage/tests - test_macro.py:1.2

Shane Hathaway cvs-admin at zope.org
Wed Nov 5 15:04:51 EST 2003


Update of /cvs-repository/Products/CompositePage/tests
In directory cvs.zope.org:/tmp/cvs-serv24456/tests

Modified Files:
	test_macro.py 
Log Message:
Refactored to allow templates to use renderMacro().

It may make more sense for templates to choose which macro to render
rather than for composites to make that choice.  This refactoring makes
that possible.


=== Products/CompositePage/tests/test_macro.py 1.1 => 1.2 ===
--- Products/CompositePage/tests/test_macro.py:1.1	Sat Oct  4 14:10:05 2003
+++ Products/CompositePage/tests/test_macro.py	Wed Nov  5 15:04:51 2003
@@ -24,6 +24,12 @@
 from Products.CompositePage.macro import renderMacro
 from Products.CompositePage.slot import Slot
 from Products.CompositePage.composite import Composite
+from AccessControl.SecurityManagement import noSecurityManager
+from AccessControl.SecurityManager import setSecurityPolicy
+import AccessControl.User  # Get the "nobody" user defined
+
+from Products.CompositePage.tests.test_tool import PermissiveSecurityPolicy
+
 
 template_text = '''
 <html metal:define-macro="page">
@@ -49,6 +55,12 @@
         a1 = ZopePageTemplate(id="a1", text="<b>Slot A</b>")
         slot_a._setObject(a1.id, a1)
         self.composite = f.composite
+        self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy())
+        noSecurityManager()
+
+    def tearDown(self):
+        setSecurityPolicy(self.old_policy)
+        noSecurityManager()
 
 
     def assertTextEqual(self, a, b):
@@ -59,7 +71,7 @@
 
     def testRender(self):
         c = self.composite
-        rendered = renderMacro(c.template.macros["page"], c)
+        rendered = renderMacro(c.template, "page", c)
         expected = "<html><body><div><b>Slot A</b></div></body></html>"
         self.assertTextEqual(rendered, expected)
 




More information about the Zope-CVS mailing list