[Checkins] SVN: zc.selenium/trunk/src/zc/selenium/ * Implemented a test suite for selenium HTML files.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri May 9 11:52:59 EDT 2008


Log message for revision 86574:
  * Implemented a test suite for selenium HTML files.
  
  * Produced a simple ZCML directive to register those tests.
  
  * Update license ehader to ZPL.
  
  My debt to the world: tests.
  

Changed:
  A   zc.selenium/trunk/src/zc/selenium/htmltest.py
  A   zc.selenium/trunk/src/zc/selenium/meta.zcml
  U   zc.selenium/trunk/src/zc/selenium/pytest.py
  A   zc.selenium/trunk/src/zc/selenium/zcml.py

-=-
Added: zc.selenium/trunk/src/zc/selenium/htmltest.py
===================================================================
--- zc.selenium/trunk/src/zc/selenium/htmltest.py	                        (rev 0)
+++ zc.selenium/trunk/src/zc/selenium/htmltest.py	2008-05-09 15:52:58 UTC (rev 86574)
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public 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.
+#
+##############################################################################
+"""A simple hookup to make a simple Selenium HTML Table test available for the
+Zope-generated test suite.
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import os
+import zope.interface
+from zc.selenium.pytest import ISeleniumTest
+from zc.selenium.resource import ResourceBase
+
+
+class HTMLTableSeleniumTest(ResourceBase):
+    zope.interface.implementsOnly(ISeleniumTest)
+
+    filename = None
+
+    def __call__(self):
+        return open(self.filename, 'r').read()
+
+    GET = __call__
+
+def createSeleniumTest(filename):
+    return type(os.path.split(filename)[-1],
+                (HTMLTableSeleniumTest,), {'filename': filename})
+


Property changes on: zc.selenium/trunk/src/zc/selenium/htmltest.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zc.selenium/trunk/src/zc/selenium/meta.zcml
===================================================================
--- zc.selenium/trunk/src/zc/selenium/meta.zcml	                        (rev 0)
+++ zc.selenium/trunk/src/zc/selenium/meta.zcml	2008-05-09 15:52:58 UTC (rev 86574)
@@ -0,0 +1,14 @@
+<configure
+    xmlns:meta="http://namespaces.zope.org/meta">
+
+  <meta:directives namespace="http://namespaces.zope.org/test">
+
+    <meta:directive
+        name="seleniumTest"
+        schema=".zcml.ISeleniumTest"
+        handler=".zcml.seleniumTest"
+        />
+
+  </meta:directives>
+
+</configure>


Property changes on: zc.selenium/trunk/src/zc/selenium/meta.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: zc.selenium/trunk/src/zc/selenium/pytest.py
===================================================================
--- zc.selenium/trunk/src/zc/selenium/pytest.py	2008-05-09 15:05:22 UTC (rev 86573)
+++ zc.selenium/trunk/src/zc/selenium/pytest.py	2008-05-09 15:52:58 UTC (rev 86574)
@@ -1,15 +1,14 @@
 ##############################################################################
 #
-# Copyright (c) 2005 Zope Corporation. All Rights Reserved.
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
 #
-# This software is subject to the provisions of the Zope Visible Source
-# License, Version 1.0 (ZVSL).  A copy of the ZVSL should accompany this
-# distribution.
-#
+# This software is subject to the provisions of the Zope Public 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
+# FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
 """Infrastructure to allow sellenium tests to be written in Python

Added: zc.selenium/trunk/src/zc/selenium/zcml.py
===================================================================
--- zc.selenium/trunk/src/zc/selenium/zcml.py	                        (rev 0)
+++ zc.selenium/trunk/src/zc/selenium/zcml.py	2008-05-09 15:52:58 UTC (rev 86574)
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public 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.
+#
+##############################################################################
+"""A simple directive for selenium tests.
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import os
+import zope.interface
+from zope.app.component.back35 import LayerField
+from zope.component import zcml
+from zope.app.publisher.browser import resourcemeta
+from zope.configuration.fields import Path
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.security.checker import CheckerPublic, NamesChecker
+from zope.security.zcml import Permission
+from zc.selenium import htmltest
+
+class ISeleniumTest(zope.interface.Interface):
+    """A directive to register an HTML selenium test with the selenium test
+    runner."""
+
+    file = Path(
+        title=u"File",
+        description=u"The file the HTML selenium test.",
+        required=True
+        )
+
+    layer = LayerField(
+        title=u"The layer the resource should be found in",
+        description=u"""
+        For information on layers, see the documentation for the skin
+        directive. Defaults to "default".""",
+        required=False
+        )
+
+    permission = Permission(
+        title=u"The permission needed to access the resource.",
+        description=u"""
+        If a permission isn't specified, the resource will always be
+        accessible.""",
+        required=False
+        )
+
+def seleniumTest(_context, file, layer=IBrowserRequest,
+                 permission='zope.Public'):
+
+    if permission == 'zope.Public':
+        permission = CheckerPublic
+
+    checker = NamesChecker(resourcemeta.allowed_names, permission)
+
+    SeleniumTestFactory = htmltest.createSeleniumTest(str(file))
+    SeleniumTestFactory.__Security_checker__ = checker
+    name = os.path.split(file)[-1]
+
+    zcml.adapter(_context,
+                 factory=(SeleniumTestFactory,), for_=(layer,), name=name)


Property changes on: zc.selenium/trunk/src/zc/selenium/zcml.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list