[Checkins] SVN: zope.app.pagetemplate/trunk/ Refactored nested macro test from a functional test into a unit test. This allowed to remove the last outside zope.app dependencies.
Hanno Schlichting
hannosch at hannosch.eu
Wed Dec 16 17:06:45 EST 2009
Log message for revision 106660:
Refactored nested macro test from a functional test into a unit test. This allowed to remove the last outside zope.app dependencies.
Changed:
U zope.app.pagetemplate/trunk/CHANGES.txt
U zope.app.pagetemplate/trunk/setup.py
D zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/ftesting.zcml
D zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/configure.zcml
U zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/inner.pt
U zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/intermediate.pt
U zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.py
D zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.txt
-=-
Modified: zope.app.pagetemplate/trunk/CHANGES.txt
===================================================================
--- zope.app.pagetemplate/trunk/CHANGES.txt 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/CHANGES.txt 2009-12-16 22:06:45 UTC (rev 106660)
@@ -5,6 +5,9 @@
3.8.0 (unreleased)
------------------
+- Refactored nested macro test from a functional test into a unit test. This
+ allowed to remove the last outside zope.app dependencies.
+
- Fixed undeclared testing dependency on zope.app.component.
- Copy trivial NoTraverser class from zope.app.publication to avoid a ZCML
Modified: zope.app.pagetemplate/trunk/setup.py
===================================================================
--- zope.app.pagetemplate/trunk/setup.py 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/setup.py 2009-12-16 22:06:45 UTC (rev 106660)
@@ -34,8 +34,6 @@
long_description=(
read('README.txt')
+ '\n\n.. contents::\n\n' +
- read('src', 'zope', 'app', 'pagetemplate', 'tests', 'test_nested.txt')
- + '\n\n' +
read('src', 'zope', 'app', 'pagetemplate', 'namedtemplate.txt')
+ '\n\n' +
read('CHANGES.txt')
@@ -56,7 +54,6 @@
'zope.component [hook]',
'zope.configuration',
'zope.dublincore',
- 'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.pagetemplate>=3.5.0',
@@ -68,11 +65,7 @@
'zope.traversing',
],
extras_require={
- "test": ['zope.container',
- 'zope.securitypolicy',
- 'zope.app.testing',
- 'zope.app.zcmlfiles',
- ],
+ "test": ['zope.container'],
},
zip_safe=False,
)
Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/ftesting.zcml
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/ftesting.zcml 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/ftesting.zcml 2009-12-16 22:06:45 UTC (rev 106660)
@@ -1,40 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="zope"
- package="zope.app.pagetemplate"
- >
-
- <!-- This file is the equivalent of site.zcml and it is -->
- <!-- used for functional testing setup -->
-
- <include package="zope.securitypolicy" file="meta.zcml" />
-
- <include package="zope.app.zcmlfiles" />
- <include package="zope.app.zcmlfiles" file="ftesting.zcml" />
- <include package="zope.app.authentication" />
- <include package="zope.securitypolicy" />
-
- <securityPolicy
- component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
- <role id="zope.Manager" title="Site Manager" />
-
- <grantAll role="zope.Manager" />
-
- <!-- Principal that tests generally run as -->
- <principal
- id="zope.mgr"
- title="Manager"
- login="mgr"
- password="mgrpw" />
-
- <!-- Bootstrap principal used to make local grant to the principal above -->
- <principal
- id="zope.globalmgr"
- title="Manager"
- login="globalmgr"
- password="globalmgrpw" />
-
- <grant role="zope.Manager" principal="zope.globalmgr" />
-
-</configure>
Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/configure.zcml
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/configure.zcml 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/configure.zcml 2009-12-16 22:06:45 UTC (rev 106660)
@@ -1,24 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/browser">
-
- <page
- for="zope.interface.Interface"
- name="inner"
- template="inner.pt"
- permission="zope.Public"
- />
-
- <page
- for="zope.interface.Interface"
- name="intermediate"
- template="intermediate.pt"
- permission="zope.Public"
- />
-
- <page
- for="zope.interface.Interface"
- name="outer"
- template="outer.pt"
- permission="zope.Public"
- />
-
-</configure>
Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/inner.pt
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/inner.pt 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/inner.pt 2009-12-16 22:06:45 UTC (rev 106660)
@@ -1,4 +1,4 @@
-<html metal:use-macro='context/@@intermediate/intermediate'>
+<html metal:use-macro="python:intermediate.macros['intermediate']">
<body>
hello
<div metal:fill-slot="body">
Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/intermediate.pt
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/intermediate.pt 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/intermediate.pt 2009-12-16 22:06:45 UTC (rev 106660)
@@ -1,5 +1,5 @@
-<html metal:define-macro='intermediate'
- metal:extend-macro='context/@@outer/main'>
+<html metal:define-macro="intermediate"
+ metal:extend-macro="python:outer.macros['main']">
<body>
hello
<div metal:fill-slot="body">
Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.py 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.py 2009-12-16 22:06:45 UTC (rev 106660)
@@ -2,17 +2,62 @@
"""
__docformat__ = "reStructuredText"
-import os
-from zope.app.testing.functional import ZCMLLayer
+import unittest
-PageTemplateLayer = ZCMLLayer(
- os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
- __name__, 'PageTemplateLayer', allow_teardown=True)
+from zope.component.testing import PlacelessSetup
+from zope.publisher.browser import TestRequest
-import zope.app.testing.functional
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+class Context(object):
+ pass
+
+
+class View(object):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+
+EXPECTED = u"""\
+<html>
+<head>
+<title>Example: outer</title>
+</head>
+<body>
+hello
+<div>
+<div>
+inner body slot content
+</div>
+intermediate body slot stuff
+</div>
+</body>
+</html>
+"""
+
+
+class Test(PlacelessSetup, unittest.TestCase):
+
+ def testMacroExtension(self):
+ # This test demonstrates how macro extension allows a macro to extend
+ # and re-offer a slot for a client template to fill.
+ outer = ViewPageTemplateFile('outer.pt')
+ intermediate = ViewPageTemplateFile('intermediate.pt')
+ inner = ViewPageTemplateFile('inner.pt')
+
+ context = Context()
+ request = TestRequest()
+ view = View(context, request)
+ self.failUnless('outer body slot' in outer(view))
+
+ namespace = inner.pt_getContext(view, request)
+ namespace['outer'] = outer
+ namespace['intermediate'] = intermediate
+ result = inner.pt_render(namespace)
+ self.assertEquals(result, EXPECTED)
+
+
def test_suite():
- suite = zope.app.testing.functional.FunctionalDocFileSuite(
- "test_nested.txt")
- suite.layer = PageTemplateLayer
- return suite
+ loader=unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.txt
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.txt 2009-12-16 20:54:06 UTC (rev 106659)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_nested.txt 2009-12-16 22:06:45 UTC (rev 106660)
@@ -1,33 +0,0 @@
-===============
-Macro extension
-===============
-
-This test demonstrates how macro extension allows a macro to extend
-and re-offer a slot for a client template to fill. This is likely not
-the best place for this test, but it demonstrates how to use the macro
-extension feature in context.
-
-Let's look at our test view using the root folder to make sure we're
-seeing the expected template expansion::
-
- >>> print http("""
- ... GET /@@inner HTTP/1.1
- ... Authorization: Basic mgr:mgrpw
- ... """, handle_errors=False)
- HTTP/1.1 200 ...
- <BLANKLINE>
- <html>
- <head>
- <title>Example: outer</title>
- </head>
- <body>
- hello
- <div>
- <div>
- inner body slot content
- </div>
- intermediate body slot stuff
- </div>
- </body>
- </html>
- <BLANKLINE>
More information about the checkins
mailing list