[Checkins] SVN: zc.selenium/branches/wosc-zope2/src/zc/selenium/ - wrote self-test for file-based tests

Wolfgang Schnerring wosc at wosc.de
Thu Feb 19 03:04:45 EST 2009


Log message for revision 96721:
   - wrote self-test for file-based tests
   - updated file-based tests to be views, not resources
  

Changed:
  A   zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.html
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/zcml.py

-=-
Added: zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.html
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.html	                        (rev 0)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.html	2009-02-19 08:04:45 UTC (rev 96721)
@@ -0,0 +1,41 @@
+<html>
+<head>
+<title>File-based Test.</title>
+<style type="text/css">
+
+.longpath:before {
+  content: "(";
+  font-size: 90%;
+  }
+
+.longpath {
+  font-size: 90%;
+  }
+
+.longpath:after {
+  content: ")";
+  font-size: 90%;
+  }
+
+</style>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<tbody>
+<tr>
+<td rowspan="1" colspan="3">
+<h1>File-based Test.</h1>
+</td>
+</tr>
+
+<tr class="open">
+<td>open</td>
+<td>/</td>
+<td></td>
+</tr>
+<tr class="verifyTextPresent">
+<td>verifyTextPresent</td>
+<td>regexp:Login|Zope Quick Start</td>
+<td></td>
+</tr>
+</tbody></table></body></html>
\ No newline at end of file

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.py	2009-02-19 07:16:00 UTC (rev 96720)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/htmltest.py	2009-02-19 08:04:45 UTC (rev 96721)
@@ -21,22 +21,27 @@
 import zope.interface
 from zope.app.component import hooks
 from zc.selenium.pytest import ISeleniumTest
-from zc.selenium.resource import ResourceBase
 from z3c.zrtresource import processor, replace
 
 
-class HTMLTableSeleniumTest(ResourceBase):
+class HTMLTableSeleniumTest(object):
     zope.interface.implementsOnly(ISeleniumTest)
 
     filename = None
 
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def browserDefault(self, request):
+        return self, ()
+
     def __call__(self):
         data = open(self.filename, 'r').read()
         p = processor.ZRTProcessor(data, commands={'replace': replace.Replace})
         self.request.response.setHeader('Content-type', 'text/html')
         return p.process(hooks.getSite(), self.request)
 
-    GET = __call__
 
 def createSeleniumTest(filename):
     return type(os.path.split(filename)[-1],

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml	2009-02-19 07:16:00 UTC (rev 96720)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml	2009-02-19 08:04:45 UTC (rev 96721)
@@ -1,5 +1,7 @@
 <configure
-  xmlns="http://namespaces.zope.org/zope">
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:test="http://namespaces.zope.org/test"
+  >
 
   <!-- provides is only necessary for zope2 -->
   <adapter
@@ -9,4 +11,7 @@
     permission="zope.Public"
     />
 
+  <include package="zc.selenium" file="meta.zcml" />
+
+  <test:seleniumTest file="htmltest.html" />
 </configure>

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/zcml.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/zcml.py	2009-02-19 07:16:00 UTC (rev 96720)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/zcml.py	2009-02-19 08:04:45 UTC (rev 96721)
@@ -18,15 +18,15 @@
 __docformat__ = "reStructuredText"
 import os
 import zope.interface
-from zope.app.component.back35 import LayerField
+from zope.schema import InterfaceField
+from zope.app.publisher.browser import viewmeta
 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.publisher.interfaces.browser import IDefaultBrowserLayer
 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."""
@@ -37,7 +37,7 @@
         required=True
         )
 
-    layer = LayerField(
+    layer = InterfaceField(
         title=u"The layer the resource should be found in",
         description=u"""
         For information on layers, see the documentation for the skin
@@ -53,17 +53,18 @@
         required=False
         )
 
-def seleniumTest(_context, file, layer=IBrowserRequest,
+def seleniumTest(_context, file, layer=IDefaultBrowserLayer,
                  permission='zope.Public'):
 
-    if permission == 'zope.Public':
-        permission = CheckerPublic
+#     if permission == 'zope.Public':
+#         permission = CheckerPublic
 
-    checker = NamesChecker(resourcemeta.allowed_names, permission)
+#     checker = NamesChecker(resourcemeta.allowed_names, permission)
 
     SeleniumTestFactory = htmltest.createSeleniumTest(str(file))
-    SeleniumTestFactory.__Security_checker__ = checker
+    #SeleniumTestFactory.__Security_checker__ = checker
     name = os.path.split(file)[-1]
 
-    zcml.adapter(_context,
-                 factory=(SeleniumTestFactory,), for_=(layer,), name=name)
+    zcml.adapter(_context, factory=(SeleniumTestFactory,),
+                 for_=(zope.interface.Interface, layer), name=name,
+                 permission=permission)



More information about the Checkins mailing list