[Checkins] SVN: z3c.website/trunk/src/z3c/website/ Added test setup

Roger Ineichen roger at projekt01.ch
Thu May 24 08:31:37 EDT 2007


Log message for revision 75933:
  Added test setup
  Added unit tests for sample data generation
  

Changed:
  U   z3c.website/trunk/src/z3c/website/sampledata/README.txt
  A   z3c.website/trunk/src/z3c/website/sampledata/tests.py
  A   z3c.website/trunk/src/z3c/website/testing.py

-=-
Modified: z3c.website/trunk/src/z3c/website/sampledata/README.txt
===================================================================
--- z3c.website/trunk/src/z3c/website/sampledata/README.txt	2007-05-24 12:10:51 UTC (rev 75932)
+++ z3c.website/trunk/src/z3c/website/sampledata/README.txt	2007-05-24 12:31:36 UTC (rev 75933)
@@ -14,13 +14,87 @@
 -----------------
 
   >>> browser.open('http://localhost/@@managesamples.html')
-  >>> browser.getLink(text='z3c.website.site').click()
+  >>> browser.getLink(text='z3c.website').click()
   >>> browser.url
   'http://localhost/@@generatesample.html?manager=z3c.website'
 
 Now we fill in the form and generate the sample site.
 
   >>> browser.getControl(name='generator.seed').value = 'sample'
-  >>> browser.getControl(name='z3c.website.site.__name__').value = 'xpo'
+  >>> browser.getControl(name='z3c.website.site.__name__').value = 'z3c'
   >>> browser.getControl(name='z3c.website.site.title').value = 'Z3C'
   >>> browser.getControl('Generate').click()
+
+Let's access the new z3c website within the skin:
+
+  >>> browser.open('http://localhost/++skin++Z3CWebSite/z3c')
+  >>> browser.url
+  'http://localhost/++skin++Z3CWebSite/z3c'
+
+Thre is also content:
+
+  >>> browser.open('http://localhost/++skin++Z3CWebSite/z3c/contact/index.html')
+  >>> browser.url
+  'http://localhost/++skin++Z3CWebSite/z3c/contact/index.html'
+
+  >>> print browser.contents
+  <!DOCTYPE ...
+  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
+        lang="en">
+  <head>
+  <title>z3c.org: Contact</title><meta http-equiv="cache-control" content="no-cache" />
+  <meta http-equiv="pragma" content="no-cache" />
+  <script type="text/javascript">
+    var contextURL='http://localhost/++skin++Z3CWebSite/z3c/contact/';
+    var viewURL='http://localhost/++skin++Z3CWebSite/z3c/contact/index.html/'</script>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/xmlhttp.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/json.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/jquery.pack.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/jsonform.validate.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/interface.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/jquery.resteditor.js">
+  </script>
+  <BLANKLINE>
+  <script type="text/javascript"
+          src="http://localhost/++skin++Z3CWebSite/z3c/@@/demo.js">
+  </script>
+  <BLANKLINE>
+  <link type="text/css" rel="stylesheet"
+        href="http://localhost/++skin++Z3CWebSite/z3c/@@/div-form.css"
+        media="all" />
+  <BLANKLINE>
+  <link type="text/css" rel="stylesheet"
+        href="http://localhost/++skin++Z3CWebSite/z3c/@@/jsonform.validate.css"
+        media="all" />
+  <BLANKLINE>
+  <link type="text/css" rel="stylesheet"
+        href="http://localhost/++skin++Z3CWebSite/z3c/@@/demo.css"
+        media="all" />
+  <BLANKLINE>
+  <link type="text/css" rel="stylesheet"
+        href="http://localhost/++skin++Z3CWebSite/z3c/@@/resteditor.css"
+        media="all" />
+  <BLANKLINE>
+  <link rel="icon" type="image/png"
+        href="http://localhost/++skin++Z3CWebSite/z3c/@@/favicon.png" />
+  </head>
+  <body>
+  ...
+  </body>
+  </html>

Added: z3c.website/trunk/src/z3c/website/sampledata/tests.py
===================================================================
--- z3c.website/trunk/src/z3c/website/sampledata/tests.py	                        (rev 0)
+++ z3c.website/trunk/src/z3c/website/sampledata/tests.py	2007-05-24 12:31:36 UTC (rev 75933)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2007 Projekt01 GmbH and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Resource License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""
+$Id: __init__.py 40 2007-02-21 09:18:28Z roger.ineichen $
+"""
+__docformat__ = 'restructuredtext'
+
+import doctest
+import unittest
+from zope.app.testing import setup
+from zope.testing.doctestunit import DocFileSuite
+
+from z3c.website import testing
+
+
+def setUp(test):
+    test.globs = {'root': setup.placefulSetUp(True)}
+
+
+def tearDown(test):
+    setup.placefulTearDown()
+
+
+def test_suite():
+
+    return unittest.TestSuite((
+        testing.FunctionalDocFileSuite('README.txt'),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+

Added: z3c.website/trunk/src/z3c/website/testing.py
===================================================================
--- z3c.website/trunk/src/z3c/website/testing.py	                        (rev 0)
+++ z3c.website/trunk/src/z3c/website/testing.py	2007-05-24 12:31:36 UTC (rev 75933)
@@ -0,0 +1,74 @@
+##############################################################################
+#
+# Copyright (c) 2007 Projekt01 GmbH and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Resource License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""
+$Id: __init__.py 40 2007-02-21 09:18:28Z roger.ineichen $
+"""
+
+import os
+from zope.testing import doctest
+
+from zope.app.testing import setup
+from zope.app.testing import functional
+from zope.app.testing.functional import ZCMLLayer
+
+import z3c.testing
+
+
+###############################################################################
+#
+# Test Component
+#
+###############################################################################
+
+WebSiteLayer = os.path.join('etc', 'ftesting.zcml')
+WebSiteLayer = os.path.abspath(WebSiteLayer)
+WebSiteLayer = ZCMLLayer(WebSiteLayer, __name__, 'Functional')
+
+
+def getRootFolder():
+    return functional.FunctionalTestSetup().getRootFolder()
+
+
+###############################################################################
+#
+# Doctest setup
+#
+###############################################################################
+
+def doctestSetUp(test):
+    pass
+
+
+def doctestTearDown(test):
+    pass
+
+
+def FunctionalDocFileSuite(path, **kw):
+    """Including relative path setup."""
+    globs = {'getRootFolder': getRootFolder}
+    if 'globs' in kw:
+        globs.update(kw['globs'])
+        del kw['globs']
+
+    kw['setUp'] = kw.get('setUp', doctestSetUp)
+    kw['tearDown'] = kw.get('tearDown', doctestTearDown)
+    if 'package' not in kw:
+        kw['package'] = doctest._normalize_module(kw.get('package', None))
+    kw['module_relative'] = kw.get('module_relative', True)
+
+    suite = functional.FunctionalDocFileSuite(path,
+        optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE,
+        globs=globs, **kw)
+    suite.layer = WebSiteLayer
+    return suite



More information about the Checkins mailing list