[Checkins] SVN: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/ fix cleaning up the document

Jan-Wijbrand Kolman janwijbrand at gmail.com
Thu Jun 3 09:07:22 EDT 2010


Log message for revision 113001:
  fix cleaning up the document

Changed:
  U   gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py
  U   gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py

-=-
Modified: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py
===================================================================
--- gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py	2010-06-03 12:42:37 UTC (rev 113000)
+++ gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py	2010-06-03 13:07:21 UTC (rev 113001)
@@ -23,6 +23,8 @@
 
 import gocept.selenium.base
 
+_suffix = 'gocept.selenium.static'
+
 class StaticFilesLayer(gocept.selenium.base.Layer):
 
     host = 'localhost'
@@ -31,7 +33,7 @@
     def setUp(self):
         super(StaticFilesLayer, self).setUp()
         self.server = None
-        self.documentroot = tempfile.mkdtemp(suffix='tha.selenium.staticfiles')
+        self.documentroot = tempfile.mkdtemp(suffix=_suffix)
         self.start_server()
 
     def start_server(self):
@@ -59,8 +61,9 @@
     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.
-        shutil.rmtree(self.documentroot)
-        self.documentroot = tempfile.mkdtemp(suffix='doctree.tinydocbook')
+        paths = os.listdir(self.documentroot)
+        for path in paths:
+            shutil.rmtree(path)
 
 static_files_layer = StaticFilesLayer()
 

Modified: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py
===================================================================
--- gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py	2010-06-03 12:42:37 UTC (rev 113000)
+++ gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py	2010-06-03 13:07:21 UTC (rev 113001)
@@ -13,12 +13,15 @@
 ##############################################################################
 
 import os
+import shutil
 import tempfile
+import time
 import unittest
 
+import gocept.selenium.tests.fixture
 import gocept.selenium.static
 
-class TestStaticFilesTestCase(unittest.TestCase):
+class TestStaticFilesLayer(unittest.TestCase):
 
     def setUp(self):
         self.testlayer = gocept.selenium.static.StaticFilesLayer()
@@ -51,3 +54,23 @@
         self.assert_(self.testlayer.server.pid)
         self.testlayer.stop_server()
         self.assert_(not self.testlayer.server)
+
+class TestStaticFilesTestCase(gocept.selenium.static.StaticFilesTestCase):
+
+    def test_server_started(self):
+        self.assert_(self.layer.server)
+
+    def test_documentroot(self):
+        default_tmp_dir = tempfile.gettempdir()
+        self.assert_(self.testlayer.documentroot.startswith(default_tmp_dir))
+
+    def test_using_selenese(self):
+        fixtures = os.path.dirname(gocept.selenium.tests.fixture.__file__)
+        shutil.copy(
+            os.path.join(fixtures, 'alert.pt'),
+            os.path.join(self.documentroot, 'alert.html'))
+
+        self.selenium.open('/alert.html')
+        self.selenium.verifyAlertNotPresent()
+        self.selenium.waitForAlertPresent()
+        self.selenium.getAlert()



More information about the checkins mailing list