[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/session/ftests.py Session functional test

Stuart Bishop stuart at stuartbishop.net
Wed Jul 14 23:15:14 EDT 2004


Log message for revision 26548:
  Session functional test
  


Changed:
  A   Zope3/trunk/src/zope/app/session/ftests.py


-=-
Added: Zope3/trunk/src/zope/app/session/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/session/ftests.py	2004-07-15 03:14:38 UTC (rev 26547)
+++ Zope3/trunk/src/zope/app/session/ftests.py	2004-07-15 03:15:14 UTC (rev 26548)
@@ -0,0 +1,73 @@
+# -*- coding: ascii -*-
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+"""
+$Id: tests.py 26427 2004-07-12 16:05:02Z Zen $
+"""
+import unittest
+from zope.app.tests.functional import BrowserTestCase
+from zope.app.zptpage.zptpage import ZPTPage
+
+class ZPTSessionTest(BrowserTestCase):
+    content = u'''
+        <div tal:define="session request/session:products.foo" tal:omit-tag="">
+            <script type="text/server-python">
+                try:
+                    session['count'] += 1
+                except KeyError:
+                    session['count'] = 1
+            </script> 
+
+            <span tal:replace="session/count" />
+        </div>
+        '''
+
+    def setUp(self):
+        BrowserTestCase.setUp(self)
+        page = ZPTPage()
+        page.source = self.content
+        page.evaluateInlineCode = True
+        root = self.getRootFolder()
+        root['page'] = page
+        self.commit()
+
+    def tearDown(self):
+        root = self.getRootFolder()
+        del root['page']
+        BrowserTestCase.tearDown(self)
+
+    def fetch(self, page='/page'):
+        response = self.publish(page)
+        self.failUnlessEqual(response.getStatus(), 200)
+        return response.getBody().strip()
+
+    def test(self):
+        response1 = self.fetch()
+        self.failUnlessEqual(response1, u'1')
+        response2 = self.fetch()
+        self.failUnlessEqual(response2, u'2')
+        response3 = self.fetch()
+        self.failUnlessEqual(response3, u'3')
+
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(ZPTSessionTest),
+        ))
+
+if __name__ == '__main__':
+    unittest.main()
+
+# vim: set filetype=python ts=4 sw=4 et si
+


Property changes on: Zope3/trunk/src/zope/app/session/ftests.py
___________________________________________________________________
Name: svn:keywords "LastChangedDate Author Id LastChangedRevision LastChangedBy HeadURL"
   + 
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list