[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/session/ clean imports, remove zope.app.18n dep, merge ftests into tests

Bernd Dorn bernd.dorn at lovelysystems.com
Tue Mar 27 09:26:06 EDT 2007


Log message for revision 73731:
  clean imports, remove zope.app.18n dep, merge ftests into tests

Changed:
  D   Zope3/trunk/src/zope/app/session/ftests.py
  U   Zope3/trunk/src/zope/app/session/http.py
  A   Zope3/trunk/src/zope/app/session/i18n.py
  U   Zope3/trunk/src/zope/app/session/interfaces.py
  U   Zope3/trunk/src/zope/app/session/session.py
  U   Zope3/trunk/src/zope/app/session/tests.py

-=-
Deleted: Zope3/trunk/src/zope/app/session/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/session/ftests.py	2007-03-27 13:15:56 UTC (rev 73730)
+++ Zope3/trunk/src/zope/app/session/ftests.py	2007-03-27 13:26:04 UTC (rev 73731)
@@ -1,121 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Session functional tests.
-
-$Id$
-"""
-import unittest
-from zope.component import provideHandler, getGlobalSiteManager
-from zope.app.folder import Folder
-from zope.app.folder.interfaces import IRootFolder
-from zope.app.publication.interfaces import IBeforeTraverseEvent
-from zope.app.testing.functional import BrowserTestCase
-from zope.app.zptpage.zptpage import ZPTPage
-from zope.app.session.testing import SessionLayer
-
-from interfaces import ISession
-
-class ZPTSessionTest(BrowserTestCase):
-    content = u'''
-        <div tal:define="
-                 session request/session:products.foo;
-                 dummy python:session.__setitem__(
-                        'count',
-                        session.get('count', 0) + 1)
-                 " tal:omit-tag="">
-            <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')
-
-class VirtualHostSessionTest(BrowserTestCase):
-    def setUp(self):
-        super(VirtualHostSessionTest, self).setUp()
-        page = ZPTPage()
-        page.source = u'<div>Foo</div>'
-        page.evaluateInlineCode = True
-        root = self.getRootFolder()
-        root['folder'] = Folder()
-        root['folder']['page'] = page
-        self.commit()
-        
-        provideHandler(self.accessSessionOnRootTraverse, 
-                       (IBeforeTraverseEvent,))
-        
-    def tearDown(self):
-        getGlobalSiteManager().unregisterHandler(
-            self.accessSessionOnRootTraverse, (IBeforeTraverseEvent,))
-        
-    def accessSessionOnRootTraverse(self, event):
-        if IRootFolder.providedBy(event.object):
-            session = ISession(event.request)
-        
-    def assertCookiePath(self, path):
-        cookie = self.cookies.values()[0]
-        self.assertEqual(cookie['path'], path)
-    
-    def testShortendPath(self):
-        self.publish(
-            '/++skin++Rotterdam/folder/++vh++http:localhost:80/++/page')
-        self.assertCookiePath('/')
-        
-    def testLongerPath(self):
-        self.publish(
-            '/folder/++vh++http:localhost:80/foo/bar/++/page')
-        self.assertCookiePath('/foo/bar')
-        
-    def testDifferentHostname(self):
-        self.publish(
-            '/folder/++vh++http:foo.bar:80/++/page')
-        self.assertCookiePath('/')
-        
-def test_suite():
-    ZPTSessionTest.layer = SessionLayer
-    VirtualHostSessionTest.layer = SessionLayer
-    return unittest.TestSuite((
-        unittest.makeSuite(ZPTSessionTest),
-        unittest.makeSuite(VirtualHostSessionTest),
-        ))
-
-if __name__ == '__main__':
-    unittest.main()
-
-# vim: set filetype=python ts=4 sw=4 et si
-

Modified: Zope3/trunk/src/zope/app/session/http.py
===================================================================
--- Zope3/trunk/src/zope/app/session/http.py	2007-03-27 13:15:56 UTC (rev 73730)
+++ Zope3/trunk/src/zope/app/session/http.py	2007-03-27 13:26:04 UTC (rev 73731)
@@ -31,7 +31,7 @@
 from zope.publisher.interfaces.http import IHTTPApplicationRequest
 from zope.annotation.interfaces import IAttributeAnnotatable
 
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.session.i18n import ZopeMessageFactory as _
 from zope.app.session.interfaces import IClientIdManager
 from zope.app.http.httpdate import build_http_date
 

Copied: Zope3/trunk/src/zope/app/session/i18n.py (from rev 73638, Zope3/trunk/src/zope/app/i18n/__init__.py)

Modified: Zope3/trunk/src/zope/app/session/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/session/interfaces.py	2007-03-27 13:15:56 UTC (rev 73730)
+++ Zope3/trunk/src/zope/app/session/interfaces.py	2007-03-27 13:26:04 UTC (rev 73731)
@@ -18,8 +18,7 @@
 from zope.interface import Interface
 from zope.interface.common.mapping import IMapping, IReadMapping, IWriteMapping
 from zope import schema
-from zope.app.container.interfaces import IContainer
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.session.i18n import ZopeMessageFactory as _
 
 __docformat__ = 'restructuredtext'
 

Modified: Zope3/trunk/src/zope/app/session/session.py
===================================================================
--- Zope3/trunk/src/zope/app/session/session.py	2007-03-27 13:15:56 UTC (rev 73730)
+++ Zope3/trunk/src/zope/app/session/session.py	2007-03-27 13:26:04 UTC (rev 73731)
@@ -16,7 +16,7 @@
 $Id$
 """
 from cStringIO import StringIO
-import sha, time, string, random, hmac, warnings, thread, zope.interface
+import time, string, random, thread
 from UserDict import IterableUserDict
 from heapq import heapify, heappop
 
@@ -26,7 +26,6 @@
 from persistent import Persistent
 from BTrees.OOBTree import OOBTree
 
-from zope import schema
 from zope.interface import implements
 from zope.component import getUtility, adapts
 from zope.component.interfaces import ComponentLookupError
@@ -37,8 +36,6 @@
         IClientIdManager, IClientId, ISession, ISessionDataContainer, \
         ISessionPkgData, ISessionData
 
-from http import ICookieClientIdManager
-
 __docformat__ = 'restructuredtext'
 
 cookieSafeTrans = string.maketrans("+/", "-.")

Modified: Zope3/trunk/src/zope/app/session/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/session/tests.py	2007-03-27 13:15:56 UTC (rev 73730)
+++ Zope3/trunk/src/zope/app/session/tests.py	2007-03-27 13:26:04 UTC (rev 73731)
@@ -16,7 +16,7 @@
 $Id$
 """
 from cStringIO import StringIO
-import unittest, os, os.path, sys
+import unittest, os, os.path
 from zope.testing import doctest
 from zope.app import zapi
 from zope.app.testing import ztapi, placelesssetup
@@ -35,13 +35,20 @@
 from zope.publisher.interfaces import IRequest
 from zope.publisher.http import HTTPRequest
 
-from zope.pagetemplate.pagetemplate import PageTemplate
-
 from zope.app.appsetup.tests import TestBootstrapSubscriber, EventStub
 from zope.app.appsetup.bootstrap import bootStrapSubscriber
 from zope.app.session.bootstrap import bootStrapSubscriber as \
      sessionBootstrapSubscriber
 
+from zope.component import provideHandler, getGlobalSiteManager
+from zope.app.folder import Folder
+from zope.app.folder.interfaces import IRootFolder
+from zope.app.publication.interfaces import IBeforeTraverseEvent
+from zope.app.testing.functional import BrowserTestCase
+from zope.app.zptpage.zptpage import ZPTPage
+from zope.app.session.testing import SessionLayer
+
+
 def setUp(session_data_container_class=PersistentSessionDataContainer):
     placelesssetup.setUp()
     ztapi.provideAdapter(IRequest, IClientId, ClientId)
@@ -95,14 +102,104 @@
     transaction.abort()
 
 
+
+
+from interfaces import ISession
+
+class ZPTSessionTest(BrowserTestCase):
+    content = u'''
+        <div tal:define="
+                 session request/session:products.foo;
+                 dummy python:session.__setitem__(
+                        'count',
+                        session.get('count', 0) + 1)
+                 " tal:omit-tag="">
+            <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')
+
+class VirtualHostSessionTest(BrowserTestCase):
+    def setUp(self):
+        super(VirtualHostSessionTest, self).setUp()
+        page = ZPTPage()
+        page.source = u'<div>Foo</div>'
+        page.evaluateInlineCode = True
+        root = self.getRootFolder()
+        root['folder'] = Folder()
+        root['folder']['page'] = page
+        self.commit()
+        
+        provideHandler(self.accessSessionOnRootTraverse, 
+                       (IBeforeTraverseEvent,))
+        
+    def tearDown(self):
+        getGlobalSiteManager().unregisterHandler(
+            self.accessSessionOnRootTraverse, (IBeforeTraverseEvent,))
+        
+    def accessSessionOnRootTraverse(self, event):
+        if IRootFolder.providedBy(event.object):
+            session = ISession(event.request)
+        
+    def assertCookiePath(self, path):
+        cookie = self.cookies.values()[0]
+        self.assertEqual(cookie['path'], path)
+    
+    def testShortendPath(self):
+        self.publish(
+            '/++skin++Rotterdam/folder/++vh++http:localhost:80/++/page')
+        self.assertCookiePath('/')
+        
+    def testLongerPath(self):
+        self.publish(
+            '/folder/++vh++http:localhost:80/foo/bar/++/page')
+        self.assertCookiePath('/foo/bar')
+        
+    def testDifferentHostname(self):
+        self.publish(
+            '/folder/++vh++http:foo.bar:80/++/page')
+        self.assertCookiePath('/')
+
+
 def test_suite():
+    ZPTSessionTest.layer = SessionLayer
+    VirtualHostSessionTest.layer = SessionLayer
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(TestBootstrap))
     suite.addTest(doctest.DocTestSuite())
     suite.addTest(doctest.DocTestSuite('zope.app.session.session',
                                        tearDown=tearDownTransaction))
     suite.addTest(doctest.DocTestSuite('zope.app.session.http'))
+    suite.addTest(unittest.makeSuite(ZPTSessionTest))
+    suite.addTest(unittest.makeSuite(VirtualHostSessionTest))
     return suite
 
+
 if __name__ == '__main__':
     unittest.main()



More information about the Zope3-Checkins mailing list