[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/ gocept.selenium.grok builds on gocept.selenium.wsgi to add support for testing grok apps

Jan-Jaap Driessen jdriessen at thehealthagency.com
Tue Nov 9 10:43:55 EST 2010


Log message for revision 118301:
  gocept.selenium.grok builds on gocept.selenium.wsgi to add support for testing grok apps

Changed:
  A   gocept.selenium/branches/janjaapdriessen-wsgi/grok.cfg
  A   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/
  A   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py
  A   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/fixtures.py
  A   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/ftesting.zcml
  A   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/tests.py

-=-
Added: gocept.selenium/branches/janjaapdriessen-wsgi/grok.cfg
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/grok.cfg	                        (rev 0)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/grok.cfg	2010-11-09 15:43:55 UTC (rev 118301)
@@ -0,0 +1,14 @@
+[buildout]
+extends = http://svn.zope.org/repos/main/groktoolkit/trunk/grok.cfg
+parts = test
+versions = versions
+develop = .
+
+[versions]
+gocept.selenium =
+selenium = 1.0.3
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = gocept.selenium[grok, test_grok]
+defaults = ['--ignore_dir', 'wsgi', '--ignore_dir', 'ztk', '--ignore_dir', 'zope2', '--ignore_dir', 'plone', '--ignore_dir', 'static', '-v', '-c']

Added: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py	                        (rev 0)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py	2010-11-09 15:43:55 UTC (rev 118301)
@@ -0,0 +1,48 @@
+#############################################################################
+#
+# Copyright (c) 2010 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 unittest
+
+from zope.app.appsetup.testlayer import createTestDB, ZODBLayer
+from zope.app.wsgi import WSGIPublisherApplication
+from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
+
+import gocept.selenium.selenese
+from gocept.selenium.wsgi import WSGILayer
+
+class GrokLayer(ZODBLayer, WSGILayer):
+
+    application = WSGIPublisherApplication()
+
+    def setUp(self):
+        ZODBLayer.setUp(self)
+        WSGILayer.setUp(self)
+
+    def tearDown(self):
+        WSGILayer.tearDown(self)
+        ZODBLayer.tearDown(self)
+
+    def testSetUp(self):
+        # A fresh database is created in the setup of the ZODBLayer:
+        ZODBLayer.testSetUp(self)
+        # We tell the publisher to use this new database:
+        self.application.requestFactory = \
+            HTTPPublicationRequestFactory(self.db)
+
+
+# Switching the db is handled by testSetUp.
+class TestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.selenium = gocept.selenium.selenese.Selenese(
+            self.layer.selenium, self)

Added: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/fixtures.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/fixtures.py	                        (rev 0)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/fixtures.py	2010-11-09 15:43:55 UTC (rev 118301)
@@ -0,0 +1,25 @@
+#############################################################################
+#
+# Copyright (c) 2010 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 grok
+
+class App(grok.Model):
+    pass
+
+class Index(grok.View):
+
+    def render(self):
+        return '''<html><body>Hello from grok</body></html>'''
+
+

Added: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/ftesting.zcml
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/ftesting.zcml	                        (rev 0)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/ftesting.zcml	2010-11-09 15:43:55 UTC (rev 118301)
@@ -0,0 +1,49 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:grok="http://namespaces.zope.org/grok"
+  i18n_domain="gocept.selenium.grok"
+  >
+  <include package="grok" />
+
+  <grok:grok package=".fixtures" />
+
+  <!-- Typical functional testing security setup -->
+  <securityPolicy
+      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+      />
+
+  <unauthenticatedPrincipal
+      id="zope.anybody"
+      title="Unauthenticated User"
+      />
+  <unauthenticatedGroup
+      id="zope.Anybody"
+      title="Unauthenticated Users"
+      />
+  <authenticatedGroup
+      id="zope.Authenticated"
+      title="Authenticated Users"
+      />
+  <everybodyGroup
+      id="zope.Everybody"
+      title="All Users"
+      />
+
+  <grant
+      permission="zope.View"
+      principal="zope.Everybody"
+      />
+
+  <principal
+      id="zope.mgr"
+      title="Manager"
+      login="mgr"
+      password="mgrpw"
+      />
+
+  <role id="zope.Manager" title="Site Manager" />
+  <grantAll role="zope.Manager" />
+  <grant role="zope.Manager" principal="zope.mgr" />
+
+</configure>
+

Added: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/tests.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/tests.py	                        (rev 0)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/tests.py	2010-11-09 15:43:55 UTC (rev 118301)
@@ -0,0 +1,39 @@
+#############################################################################
+#
+# Copyright (c) 2010 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 unittest
+
+import transaction
+
+import gocept.selenium.grok
+from gocept.selenium.grok import GrokLayer
+from gocept.selenium.grok.fixtures import App
+
+class TestGrokTestCase(gocept.selenium.grok.TestCase):
+
+    layer = GrokLayer(gocept.selenium.grok)
+
+    def setUp(self):
+        super(TestGrokTestCase, self).setUp()
+        root = self.layer.getRootFolder()
+        root['app'] = App()
+        transaction.commit()
+
+    def test_grok_layer(self):
+        layer = self.layer
+        self.assertTrue(layer.thread.is_alive())
+
+    def test_grok_app(self):
+        self.selenium.open('/app')
+        self.selenium.assertTextPresent('Hello from grok')
+



More information about the checkins mailing list