[Checkins] SVN: zc.selenium/branches/wosc-zope2/src/zc/selenium/ - switched from customized resources to normal browser pages registered for "*"

Wolfgang Schnerring wosc at wosc.de
Mon Feb 16 05:44:53 EST 2009


Log message for revision 96582:
   - switched from customized resources to normal browser pages registered for "*"
   - added compatibility registrations for zope2 using five
   - file-based HTML tests are currently broken, that'll need to be fixed
  

Changed:
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt
  D   zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py
  D   zc.selenium/branches/wosc-zope2/src/zc/selenium/resources/tests/
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/selenium.py
  A   zc.selenium/branches/wosc-zope2/src/zc/selenium/suite.pt
  A   zc.selenium/branches/wosc-zope2/src/zc/selenium/zope2.zcml
  A   zc.selenium/branches/wosc-zope2/src/zc/selenium/zope3.zcml

-=-
Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml	2009-02-16 10:44:53 UTC (rev 96582)
@@ -2,6 +2,7 @@
 <configure
     xmlns="http://namespaces.zope.org/zope"
     xmlns:browser="http://namespaces.zope.org/browser"
+    xmlns:zcml="http://namespaces.zope.org/zcml"
     >
 
   <browser:resourceDirectory
@@ -19,29 +20,32 @@
 
   <browser:page
       for="*"
-      name="selenium_results"
+      name="zc.selenium.suite"
+      template="suite.pt"
+      permission="zope.Public"
+      />
+
+  <browser:page
+      for="*"
+      name="zc.selenium.results"
       class=".results.Results"
       permission="zope.Public"
       />
 
   <browser:page
       for="*"
-      name="selenium-push.html"
+      name="zc.selenium.db.push"
       class=".dbs.PushDBs"
       permission="zope.Public"
       />
 
   <browser:page
       for="*"
-      name="selenium-pop.html"
+      name="zc.selenium.db.pop"
       class=".dbs.PopDBs"
       permission="zope.Public"
       />
 
-  <!-- XXX module is unknown in zope2, what to do? -->
-  <!--
-  <module module=".pytest">
-    <allow attributes="suite" />
-  </module>
-  -->
+  <include file="zope3.zcml" zcml:condition="not-installed Products.Five"/>
+  <include file="zope2.zcml" zcml:condition="installed Products.Five"/>
 </configure>

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py	2009-02-16 10:44:53 UTC (rev 96582)
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Demo storage push/pop operations, as resources.
+"""Demo storage push/pop operations.
 
 $Id: dbs.py 12602 2006-07-06 06:29:48Z fred $
 """
@@ -19,11 +19,9 @@
 from ZODB.DemoStorage import DemoStorage
 from ZODB.DB import DB
 
-import zc.selenium.resource
 
+class PushDBs(object):
 
-class PushDBs(zc.selenium.resource.ResourceBase):
-
     def __call__(self):
         publication = self.request.publication
         if [1
@@ -44,7 +42,7 @@
 
         return 'Done'
 
-class PopDBs(zc.selenium.resource.ResourceBase):
+class PopDBs(object):
 
     def __call__(self):
         publication = self.request.publication

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py	2009-02-16 10:44:53 UTC (rev 96582)
@@ -74,12 +74,14 @@
 
 
 def suite(request):
-    tests = sorted(component.getAdapters([request], ISeleniumTest))
+    class Dummy(object):
+        interface.implements(interface.Interface)
+    tests = sorted(component.getAdapters((Dummy(), request), ISeleniumTest))
     if PATTERNS:
         tests = [(name, test) for name, test in tests
                  if matchesAnyPattern(name, PATTERNS)]
     return '\n'.join([
-        ('<tr><td><a href="/@@/%s">%s</a></td></tr>' % (
+        ('<tr><td><a href="/@@%s">%s</a></td></tr>' % (
              name,
              (test.__doc__ or '').strip().split('\n')[0] or name,
              )
@@ -159,6 +161,7 @@
 
 footer = '</tbody></table></body></html>'
 
+
 class Selenium:
 
     def __init__(self, request, title, message=None):
@@ -169,11 +172,11 @@
         self.server = urlparse.urlsplit(url)[1]
 
     def push(self):
-        self.open('http://%s/@@/selenium-push.html' % self.server,
+        self.open('http://%s/@@zc.selenium.db.push' % self.server,
                   lineno=False)
 
     def pop(self):
-        self.open('http://%s/@@/selenium-pop.html' % self.server,
+        self.open('http://%s/@@zc.selenium.db.pop' % self.server,
                   lineno=False)
 
     def __getattr__(self, name):
@@ -182,11 +185,16 @@
     def __str__(self):
         return ''.join(self.output) + footer
 
+
 class Test(object):
-    component.adapts(zope.publisher.interfaces.browser.IBrowserRequest)
+    component.adapts(
+        interface.Interface,
+        zope.publisher.interfaces.browser.IDefaultBrowserLayer)
+
     interface.implements(ISeleniumTest)
 
-    def __init__(self, request):
+    def __init__(self, context, request):
+        self.context = context
         self.request = request
         title = (self.__doc__ or '').split('\n')[0]
         mess = ''
@@ -212,7 +220,9 @@
         self.selenium.pop()
 
     def __call__(self):
-        tests = [name for name in dir(self) if name.startswith('test')]
+        tests = [name for name in dir(self) if name.startswith('test')
+                 # zope2 compatibility
+                 and not name.endswith('__roles__')]
         tests.sort()
         s = self.selenium
         outputDoc(self, self.sharedSetUp.__doc__, 2)

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt	2009-02-16 10:44:53 UTC (rev 96582)
@@ -79,7 +79,7 @@
 HTML table:
 
     >>> from zope.publisher.browser import TestRequest
-    >>> print Test(TestRequest())()
+    >>> print Test(None, TestRequest())()
     <html>
     <head>
     <title>My first test</title>
@@ -101,12 +101,12 @@
     <BLANKLINE>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="comment">
@@ -146,7 +146,7 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     <tr class="comment">
@@ -157,7 +157,7 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="comment lineinfo">
@@ -172,12 +172,12 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     </tbody></table></body></html>
@@ -238,7 +238,7 @@
     ...     def my_helper(self):
     ...         self.selenium.sample(frame=sys._getframe(1))
 
-    >>> print FrameSample(TestRequest())()
+    >>> print FrameSample(None, TestRequest())()
     <html>
     <head>
     <title>Frame selection example.</title>
@@ -257,7 +257,7 @@
     <BLANKLINE>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="comment">
@@ -268,7 +268,7 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="comment lineinfo">
@@ -283,12 +283,12 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     </tbody></table></body></html>
@@ -356,7 +356,7 @@
     ...         s.foo('bar')
     ...         s.baz(lineno=False)
 
-    >>> print Second(TestRequest())()
+    >>> print Second(None, TestRequest())()
     <html>
     <head>
     <title>My second test</title>
@@ -382,7 +382,7 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-push.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.push</td>
     <td></td>
     </tr>
     <tr class="comment lineinfo">
@@ -460,7 +460,7 @@
     </tr>
     <tr class="open">
     <td>open</td>
-    <td>http://127.0.0.1/@@/selenium-pop.html</td>
+    <td>http://127.0.0.1/@@zc.selenium.db.pop</td>
     <td></td>
     </tr>
     <tr class="comment lineinfo">
@@ -513,8 +513,8 @@
 compute rows for the test suite:
 
     >>> print zc.selenium.pytest.suite(TestRequest())
-    <tr><td><a href="/@@/first.html">My first test</a></td></tr>
-    <tr><td><a href="/@@/second.html">My second test</a></td></tr>
+    <tr><td><a href="/@@first.html">My first test</a></td></tr>
+    <tr><td><a href="/@@second.html">My second test</a></td></tr>
 
 For each test, a row is output with a link to the test resource and a
 link title computed from the test doc string.  The tests are output in
@@ -524,12 +524,12 @@
 
     >>> zc.selenium.pytest.selectTestsToRun(['first'])
     >>> print zc.selenium.pytest.suite(TestRequest())
-    <tr><td><a href="/@@/first.html">My first test</a></td></tr>
+    <tr><td><a href="/@@first.html">My first test</a></td></tr>
 
 or reset it
 
     >>> zc.selenium.pytest.selectTestsToRun([])
     >>> print zc.selenium.pytest.suite(TestRequest())
-    <tr><td><a href="/@@/first.html">My first test</a></td></tr>
-    <tr><td><a href="/@@/second.html">My second test</a></td></tr>
+    <tr><td><a href="/@@first.html">My first test</a></td></tr>
+    <tr><td><a href="/@@second.html">My second test</a></td></tr>
 

Deleted: zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py	2009-02-16 10:44:53 UTC (rev 96582)
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation 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.
-#
-##############################################################################
-"""Base class for zc.selenium's active resources.
-
-"""
-__docformat__ = "reStructuredText"
-
-import zope.app.publisher.browser.resource
-import zope.interface
-import zope.publisher.interfaces.browser
-
-# Zope2 compatibility
-try:
-    from zope.publisher.browser import BrowserView
-except ImportError:
-    from zope.app.publisher.browser import BrowserView
-
-
-class ResourceBase(BrowserView,
-                   zope.app.publisher.browser.resource.Resource):
-
-    zope.interface.implements(
-        zope.publisher.interfaces.browser.IBrowserPublisher)
-
-    def __init__(self, request):
-        self.request = request
-        self.context = self
-
-    def publishTraverse(self, request, name):
-        raise NotFound(None, name)
-
-    def browserDefault(self, request):
-        return getattr(self, request.method), ()

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py	2009-02-16 10:44:53 UTC (rev 96582)
@@ -13,22 +13,19 @@
 ##############################################################################
 
 """Result reporting resource for zc.selenium.
-
 """
 
 import sys
-
+import zc.selenium.selenium
 import zope.app.pagetemplate
 
-import zc.selenium.resource
 
-class Results(zc.selenium.resource.ResourceBase):
+class Results(object):
+    """Transports test results from the browser to the selenium test runner"""
 
     template = zope.app.pagetemplate.ViewPageTemplateFile('results.pt')
 
     def __call__(self):
-        # get the queue used to communicate with the test thread, this will
-        # fail horribly if not running in "Selenium test" mode
-        messages = sys.modules['__main__'].messages
-        messages.put(self.request)
+        if hasattr(zc.selenium.selenium, 'messages'):
+            zc.selenium.selenium.messages.put(self.request)
         return self.template(self)

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/selenium.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/selenium.py	2009-02-16 10:43:38 UTC (rev 96581)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/selenium.py	2009-02-16 10:44:53 UTC (rev 96582)
@@ -71,10 +71,10 @@
     old_timeout = socket.getdefaulttimeout()
     socket.setdefaulttimeout(5)
     url = base_url % {'port': port}
-    url += ('/@@/selenium/TestRunner.html'
-            '?test=tests%%2FTestSuite.html&'
+    url += ('/++resource++selenium/TestRunner.html'
+            '?test=%%2F@@zc.selenium.suite&'
             'baseUrl=%s&'
-            'resultsUrl=%s/@@/selenium_results' % (url,url,))
+            'resultsUrl=%s/@@zc.selenium.results' % (url,url,))
     time.sleep(1)
     while zope_thread.isAlive():
         try:
@@ -208,11 +208,6 @@
     global messages
     messages = Queue()
 
-    # Hack around fact that zc.selenium.results expects zope to be run
-    # from __main__:
-    if __name__ != '__main__':
-        sys.modules['__main__'] = sys.modules[__name__]
-
     options = parseOptions()
     if options.random_port:
         options.port = random_port()

Copied: zc.selenium/branches/wosc-zope2/src/zc/selenium/suite.pt (from rev 96488, zc.selenium/branches/wosc-zope2/src/zc/selenium/resources/tests/TestSuite.html)
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/suite.pt	                        (rev 0)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/suite.pt	2009-02-16 10:44:53 UTC (rev 96582)
@@ -0,0 +1,29 @@
+<html>
+<head>
+<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
+<title>Test Suite</title>
+</head>
+
+<body>
+
+<table     cellpadding="1"
+           cellspacing="1"
+           border="1">
+  <tbody>
+  <tr><td><b>Test Suite</b></td></tr>
+    <tr tal:replace="
+        structure
+        python: modules['zc.selenium.pytest'].suite(request)"
+        >
+      <td>
+        <a href="/@@/selenium-no-publish.html">
+        Make sure we can elect not to publish</a>
+      </td>
+    </tr>
+
+
+  </tbody>
+</table>
+
+</body>
+</html>


Property changes on: zc.selenium/branches/wosc-zope2/src/zc/selenium/suite.pt
___________________________________________________________________
Added: svn:mergeinfo
   + 

Added: zc.selenium/branches/wosc-zope2/src/zc/selenium/zope2.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/zope2.zcml	                        (rev 0)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/zope2.zcml	2009-02-16 10:44:53 UTC (rev 96582)
@@ -0,0 +1,12 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:five="http://namespaces.zope.org/five"
+  >
+
+
+  <five:traversable class="OFS.Application.Application" />
+  <five:implements
+    class="OFS.Application.Application"
+    interface="zope.app.component.interfaces.ISite"
+    />
+</configure>
\ No newline at end of file

Added: zc.selenium/branches/wosc-zope2/src/zc/selenium/zope3.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/zope3.zcml	                        (rev 0)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/zope3.zcml	2009-02-16 10:44:53 UTC (rev 96582)
@@ -0,0 +1,8 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  >
+
+  <module module=".pytest">
+    <allow attributes="suite" />
+  </module>
+</configure>
\ No newline at end of file



More information about the Checkins mailing list