[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ Remove ``switch_db`` contract, since it is the exception rather than the rule

Wolfgang Schnerring wosc at wosc.de
Thu Nov 18 05:43:21 EST 2010


Log message for revision 118461:
  Remove ``switch_db`` contract, since it is the exception rather than the rule
  
  The ztk/ and grok/ Layers need it, but the others (zope2/plone/static) don't,
  and we can just as well do this work in the Layer.testSetUp or TestCase.setUp (depending on where it's needed)
  

Changed:
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/__init__.py
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/tests/test_static.py
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/zope2/__init__.py
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py

-=-
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py	2010-11-18 10:16:10 UTC (rev 118460)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py	2010-11-18 10:43:21 UTC (rev 118461)
@@ -49,14 +49,13 @@
     def tearDown(self):
         self.selenium.stop()
 
-    def switch_db(self):
-        raise NotImplemented
+    def testSetUp(self):
+        pass
 
 
 class TestCase(object):
 
     def setUp(self):
         super(TestCase, self).setUp()
-        self.layer.switch_db()
         self.selenium = gocept.selenium.selenese.Selenese(
             self.layer.selenium, self)

Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/__init__.py	2010-11-18 10:16:10 UTC (rev 118460)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/__init__.py	2010-11-18 10:43:21 UTC (rev 118461)
@@ -109,9 +109,8 @@
         shutil.rmtree(self.documentroot)
         super(StaticFilesLayer, self).tearDown()
 
-    def switch_db(self):
-        # Part of the gocept.selenium test layer contract. We use the
-        # hook to clear out all the files from the documentroot.
+    def testSetUp(self):
+        super(StaticFilesLayer, self).testSetUp()
         paths = os.listdir(self.documentroot)
         for path in paths:
             fullpath = os.path.join(self.documentroot, path)

Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/tests/test_static.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/tests/test_static.py	2010-11-18 10:16:10 UTC (rev 118460)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/static/tests/test_static.py	2010-11-18 10:43:21 UTC (rev 118461)
@@ -36,14 +36,14 @@
         self.assertEquals(
             ['foo.txt'], os.listdir(self.testlayer.documentroot))
 
-    def test_documentroot_empty_after_switchdb(self):
+    def test_documentroot_empty_after_testsetup(self):
         import os
         documentroot = self.testlayer.documentroot
         self.assert_(not os.listdir(self.testlayer.documentroot))
         open(os.path.join(documentroot, 'bar.txt'), 'w').write('Hello World!')
         self.assertEquals(
             ['bar.txt'], os.listdir(self.testlayer.documentroot))
-        self.testlayer.switch_db()
+        self.testlayer.testSetUp()
         self.assert_(not os.listdir(self.testlayer.documentroot))
 
     def test_server_startup_shutdown(self):

Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/zope2/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/zope2/__init__.py	2010-11-18 10:16:10 UTC (rev 118460)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/zope2/__init__.py	2010-11-18 10:43:21 UTC (rev 118461)
@@ -64,11 +64,7 @@
         Lifetime.shutdown(0, fast=1)
         super(Layer, self).tearDown()
 
-    def switch_db(self):
-        # Nothing to do, we rely on ZopeLiteLayer et. al.
-        pass
 
-
 class TestCase(gocept.selenium.base.TestCase,
                Testing.ZopeTestCase.FunctionalTestCase):
 

Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py	2010-11-18 10:16:10 UTC (rev 118460)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py	2010-11-18 10:43:21 UTC (rev 118461)
@@ -46,20 +46,20 @@
             asyncore.poll(0.1)
         self.http.close()
 
-    def switch_db(self):
-        """switches the HTTP-server's database to the currently active
-        DemoStorage"""
-        db = zope.app.testing.functional.FunctionalTestSetup().db
-        self.http.application.set_db(db)
 
-
 class TestCase(gocept.selenium.base.TestCase,
                zope.app.testing.functional.FunctionalTestCase):
     # note: MRO requires the gocept.selenium.base.TestCase to come first,
     # otherwise setUp/tearDown happens in the wrong order
-    pass
 
+    def setUp(self):
+        # switches the HTTP-server's database to the currently active
+        # DemoStorage (which is set by FunctionalTestCase)
+        super(TestCase, self).setUp()
+        db = zope.app.testing.functional.FunctionalTestSetup().db
+        self.layer.http.application.set_db(db)
 
+
 class SwitchableDBApplication(zope.app.wsgi.WSGIPublisherApplication):
 
     def __init__(self, *args, **kw):



More information about the checkins mailing list