[Checkins] SVN: gocept.selenium/trunk/src/gocept/selenium/ Move/rename common isolation fixture

Wolfgang Schnerring wosc at wosc.de
Sun Dec 26 10:59:02 EST 2010


Log message for revision 119137:
  Move/rename common isolation fixture
  

Changed:
  U   gocept.selenium/trunk/src/gocept/selenium/grok/fixtures.py
  U   gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml
  D   gocept.selenium/trunk/src/gocept/selenium/tests/fixture/dummy.py
  A   gocept.selenium/trunk/src/gocept/selenium/tests/isolation/
  A   gocept.selenium/trunk/src/gocept/selenium/tests/isolation/__init__.py
  A   gocept.selenium/trunk/src/gocept/selenium/tests/isolation/configure.zcml
  A   gocept.selenium/trunk/src/gocept/selenium/tests/isolation/views.py
  D   gocept.selenium/trunk/src/gocept/selenium/tests/isolation.py
  U   gocept.selenium/trunk/src/gocept/selenium/zope2/testing.py
  U   gocept.selenium/trunk/src/gocept/selenium/ztk/tests/ftesting.zcml

-=-
Modified: gocept.selenium/trunk/src/gocept/selenium/grok/fixtures.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/grok/fixtures.py	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/grok/fixtures.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 
-import gocept.selenium.tests.fixture.dummy
+import gocept.selenium.tests.isolation.views
 import grok
 
 
@@ -34,7 +34,7 @@
 
     def render(self):
         view = getattr(
-            gocept.selenium.tests.fixture.dummy, self.__class__.__name__)()
+            gocept.selenium.tests.isolation.views, self.__class__.__name__)()
         view.context = self.context
         return view()
 

Modified: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml	2010-12-26 15:59:02 UTC (rev 119137)
@@ -5,34 +5,6 @@
 
   <browser:page
     for="*"
-    name="set.html"
-    class=".dummy.Set"
-    permission="zope.Public"
-    />
-
-  <browser:page
-    for="*"
-    name="get.html"
-    class=".dummy.Get"
-    permission="zope.Public"
-    />
-
-  <browser:page
-    for="*"
-    name="inc-volatile.html"
-    class=".dummy.IncrementVolatile"
-    permission="zope.Public"
-    />
-
-  <browser:page
-    for="*"
-    name="error.html"
-    class=".dummy.Error"
-    permission="zope.Public"
-    />
-
-  <browser:page
-    for="*"
     name="display-delay.html"
     template="display-delay.pt"
     permission="zope.Public"

Deleted: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/dummy.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/fixture/dummy.py	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/fixture/dummy.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -1,49 +0,0 @@
-#############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-
-import zope.security.proxy
-
-
-class Set(object):
-
-    def __call__(self):
-        c = zope.security.proxy.removeSecurityProxy(self.context)
-        c.foo = 1
-        return 'setting done'
-
-
-class Get(object):
-
-    def __call__(self):
-        c = zope.security.proxy.removeSecurityProxy(self.context)
-        return str(getattr(c, 'foo', 0))
-
-
-class Error(object):
-
-    def __call__(Self):
-        raise ValueError()
-
-
-class IncrementVolatile(object):
-
-    def __call__(self):
-        c = zope.security.proxy.removeSecurityProxy(self.context)
-        if hasattr(c, 'aq_base'):
-            c = c.aq_base
-
-        if not hasattr(c, '_v_counter'):
-            c._v_counter = 0
-        c._v_counter += 1
-        return str(c._v_counter)

Copied: gocept.selenium/trunk/src/gocept/selenium/tests/isolation/__init__.py (from rev 119133, gocept.selenium/trunk/src/gocept/selenium/tests/isolation.py)
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/isolation/__init__.py	                        (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/isolation/__init__.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -0,0 +1,70 @@
+#############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+
+ENSURE_ORDER = False
+
+
+class IsolationTests(object):
+
+    # test_0_set and test_1_get verify that different test methods are isolated
+    # from each other, i.e. that the underlying DemoStorage stacking is wired
+    # up correctly
+
+    def test_0_set(self):
+        global ENSURE_ORDER
+        self.selenium.open('http://%s/set.html' % self.selenium.server)
+        self.selenium.open('http://%s/get.html' % self.selenium.server)
+        self.selenium.assertBodyText('1')
+        ENSURE_ORDER = True
+
+    def test_1_get(self):
+        global ENSURE_ORDER
+        self.assertEquals(ENSURE_ORDER, True,
+                          'Set test was not run before get test')
+        self.selenium.open('http://%s/get.html' % self.selenium.server)
+        self.selenium.assertNotBodyText('1')
+        ENSURE_ORDER = False
+
+    # subclasses need to implement getRootFolder() and getDatabase()
+    # for the tests below to work
+
+    def test_each_request_gets_a_separate_zodb_connection(self):
+        self.selenium.open(
+            'http://%s/inc-volatile.html' % self.selenium.server)
+        self.selenium.assertBodyText('1')
+        # We demonstrate isolation using volatile attributes (which are
+        # guaranteed not to be present on separate connections). But since
+        # there is no guarantee that volatile attributes disappear on
+        # transaction boundaries, we need to prevent re-use of the first
+        # connection -- to avoid trouble like "it's the same connection, so the
+        # volatile attribute is still there".
+        #
+        # The proper way to do this would be two requests that are processing
+        # concurrently, but a) gocept.selenium is not prepared for
+        # multi-threaded requests and b) simulating that would be a major pain,
+        # so we cheat and force the opening of another connection by claiming
+        # one here.
+        db = self.getDatabase()
+        conn = db.open()
+        self.selenium.open(
+            'http://%s/inc-volatile.html' % self.selenium.server)
+        conn.close()
+        self.selenium.assertBodyText('1')
+
+    def test_requests_get_different_zodb_connection_than_tests(self):
+        root = self.getRootFolder()
+        root._v_counter = 1
+        self.selenium.open(
+            'http://%s/inc-volatile.html' % self.selenium.server)
+        self.selenium.assertBodyText('1')

Copied: gocept.selenium/trunk/src/gocept/selenium/tests/isolation/configure.zcml (from rev 119133, gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml)
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/isolation/configure.zcml	                        (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/isolation/configure.zcml	2010-12-26 15:59:02 UTC (rev 119137)
@@ -0,0 +1,34 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:browser="http://namespaces.zope.org/browser"
+  >
+
+  <browser:page
+    for="*"
+    name="set.html"
+    class=".views.Set"
+    permission="zope.Public"
+    />
+
+  <browser:page
+    for="*"
+    name="get.html"
+    class=".views.Get"
+    permission="zope.Public"
+    />
+
+  <browser:page
+    for="*"
+    name="inc-volatile.html"
+    class=".views.IncrementVolatile"
+    permission="zope.Public"
+    />
+
+  <browser:page
+    for="*"
+    name="error.html"
+    class=".views.Error"
+    permission="zope.Public"
+    />
+
+</configure>

Copied: gocept.selenium/trunk/src/gocept/selenium/tests/isolation/views.py (from rev 119133, gocept.selenium/trunk/src/gocept/selenium/tests/fixture/dummy.py)
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/isolation/views.py	                        (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/isolation/views.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -0,0 +1,49 @@
+#############################################################################
+#
+# Copyright (c) 2009 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.
+#
+##############################################################################
+
+import zope.security.proxy
+
+
+class Set(object):
+
+    def __call__(self):
+        c = zope.security.proxy.removeSecurityProxy(self.context)
+        c.foo = 1
+        return 'setting done'
+
+
+class Get(object):
+
+    def __call__(self):
+        c = zope.security.proxy.removeSecurityProxy(self.context)
+        return str(getattr(c, 'foo', 0))
+
+
+class Error(object):
+
+    def __call__(Self):
+        raise ValueError()
+
+
+class IncrementVolatile(object):
+
+    def __call__(self):
+        c = zope.security.proxy.removeSecurityProxy(self.context)
+        if hasattr(c, 'aq_base'):
+            c = c.aq_base
+
+        if not hasattr(c, '_v_counter'):
+            c._v_counter = 0
+        c._v_counter += 1
+        return str(c._v_counter)

Deleted: gocept.selenium/trunk/src/gocept/selenium/tests/isolation.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/isolation.py	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/isolation.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -1,70 +0,0 @@
-#############################################################################
-#
-# Copyright (c) 2009 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.
-#
-##############################################################################
-
-ENSURE_ORDER = False
-
-
-class IsolationTests(object):
-
-    # test_0_set and test_1_get verify that different test methods are isolated
-    # from each other, i.e. that the underlying DemoStorage stacking is wired
-    # up correctly
-
-    def test_0_set(self):
-        global ENSURE_ORDER
-        self.selenium.open('http://%s/set.html' % self.selenium.server)
-        self.selenium.open('http://%s/get.html' % self.selenium.server)
-        self.selenium.assertBodyText('1')
-        ENSURE_ORDER = True
-
-    def test_1_get(self):
-        global ENSURE_ORDER
-        self.assertEquals(ENSURE_ORDER, True,
-                          'Set test was not run before get test')
-        self.selenium.open('http://%s/get.html' % self.selenium.server)
-        self.selenium.assertNotBodyText('1')
-        ENSURE_ORDER = False
-
-    # subclasses need to implement getRootFolder() and getDatabase()
-    # for the tests below to work
-
-    def test_each_request_gets_a_separate_zodb_connection(self):
-        self.selenium.open(
-            'http://%s/inc-volatile.html' % self.selenium.server)
-        self.selenium.assertBodyText('1')
-        # We demonstrate isolation using volatile attributes (which are
-        # guaranteed not to be present on separate connections). But since
-        # there is no guarantee that volatile attributes disappear on
-        # transaction boundaries, we need to prevent re-use of the first
-        # connection -- to avoid trouble like "it's the same connection, so the
-        # volatile attribute is still there".
-        #
-        # The proper way to do this would be two requests that are processing
-        # concurrently, but a) gocept.selenium is not prepared for
-        # multi-threaded requests and b) simulating that would be a major pain,
-        # so we cheat and force the opening of another connection by claiming
-        # one here.
-        db = self.getDatabase()
-        conn = db.open()
-        self.selenium.open(
-            'http://%s/inc-volatile.html' % self.selenium.server)
-        conn.close()
-        self.selenium.assertBodyText('1')
-
-    def test_requests_get_different_zodb_connection_than_tests(self):
-        root = self.getRootFolder()
-        root._v_counter = 1
-        self.selenium.open(
-            'http://%s/inc-volatile.html' % self.selenium.server)
-        self.selenium.assertBodyText('1')

Modified: gocept.selenium/trunk/src/gocept/selenium/zope2/testing.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/zope2/testing.py	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/zope2/testing.py	2010-12-26 15:59:02 UTC (rev 119137)
@@ -13,7 +13,7 @@
 ##############################################################################
 
 import Products.Five.zcml
-import gocept.selenium.tests.fixture
+import gocept.selenium.tests.isolation
 import gocept.selenium.zope2
 
 
@@ -22,7 +22,7 @@
     @classmethod
     def setUp(cls):
         Products.Five.zcml.load_config(
-            'configure.zcml', package=gocept.selenium.tests.fixture)
+            'configure.zcml', package=gocept.selenium.tests.isolation)
 
 
 # required for Zope2 >= 2.12

Modified: gocept.selenium/trunk/src/gocept/selenium/ztk/tests/ftesting.zcml
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/ztk/tests/ftesting.zcml	2010-12-26 15:52:57 UTC (rev 119136)
+++ gocept.selenium/trunk/src/gocept/selenium/ztk/tests/ftesting.zcml	2010-12-26 15:59:02 UTC (rev 119137)
@@ -3,7 +3,8 @@
   i18n_domain="zope">
 
   <include package="zope.app.zcmlfiles"/>
-  <include package="gocept.selenium.tests.fixture" file="configure.zcml"/>
+  <include package="gocept.selenium.tests.isolation" />
+  <include package="gocept.selenium.tests.fixture" />
 
   <!-- typical functional testing security setup -->
   <include package="zope.securitypolicy" file="meta.zcml"/>



More information about the checkins mailing list