[Checkins] SVN: zope.session/trunk/src/zope/session/ Make progress
with moving core components
Roger Ineichen
roger at projekt01.ch
Tue Sep 25 17:28:55 EDT 2007
Log message for revision 80055:
Make progress with moving core components
from zope.app.session to zope.session
Changed:
D zope.session/trunk/src/zope/session/ftesting.zcml
D zope.session/trunk/src/zope/session/testing.py
U zope.session/trunk/src/zope/session/tests.py
-=-
Deleted: zope.session/trunk/src/zope/session/ftesting.zcml
===================================================================
--- zope.session/trunk/src/zope/session/ftesting.zcml 2007-09-25 21:28:40 UTC (rev 80054)
+++ zope.session/trunk/src/zope/session/ftesting.zcml 2007-09-25 21:28:54 UTC (rev 80055)
@@ -1,56 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta"
- i18n_domain="zope"
- package="zope.session"
- >
-
- <!-- This file is the equivalent of site.zcml and it is -->
- <!-- used for functional testing setup -->
-
- <include package="zope.app.securitypolicy" file="meta.zcml" />
-
- <include package="zope.app.zcmlfiles" />
-
- <include package="zope.app.authentication" />
- <include package="zope.app.zptpage"/>
- <include package="zope.app.securitypolicy" />
-
- <include package="zope.session" />
-
- <securityPolicy
- component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
- <role id="zope.Anonymous" title="Everybody"
- description="All users have this role implicitly" />
- <role id="zope.Manager" title="Site Manager" />
-
- <!-- Replace the following directive if you don't want public access -->
- <grant permission="zope.View"
- role="zope.Anonymous" />
-
- <grantAll role="zope.Manager" />
-
- <!-- Principals -->
-
- <unauthenticatedPrincipal
- id="zope.anybody"
- title="Unauthenticated User" />
-
- <!-- Principal that tests generally run as -->
- <principal
- id="zope.mgr"
- title="Manager"
- login="mgr"
- password="mgrpw" />
-
- <!-- Bootstrap principal used to make local grant to the principal above -->
- <principal
- id="zope.globalmgr"
- title="Manager"
- login="globalmgr"
- password="globalmgrpw" />
-
- <grant role="zope.Manager" principal="zope.globalmgr" />
-
-</configure>
Deleted: zope.session/trunk/src/zope/session/testing.py
===================================================================
--- zope.session/trunk/src/zope/session/testing.py 2007-09-25 21:28:40 UTC (rev 80054)
+++ zope.session/trunk/src/zope/session/testing.py 2007-09-25 21:28:54 UTC (rev 80055)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 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.
-#
-##############################################################################
-"""zope.app.session common test related classes/functions/objects.
-
-$Id$
-"""
-
-__docformat__ = "reStructuredText"
-
-import os
-from zope.app.testing.functional import ZCMLLayer
-
-SessionLayer = ZCMLLayer(
- os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
- __name__, 'SessionLayer', allow_teardown=True)
-
Modified: zope.session/trunk/src/zope/session/tests.py
===================================================================
--- zope.session/trunk/src/zope/session/tests.py 2007-09-25 21:28:40 UTC (rev 80054)
+++ zope.session/trunk/src/zope/session/tests.py 2007-09-25 21:28:54 UTC (rev 80055)
@@ -23,6 +23,7 @@
from zope.app.testing import placelesssetup
import transaction
+from zope.component import provideHandler, getGlobalSiteManager
from zope.session.interfaces import IClientId, IClientIdManager, ISession
from zope.session.interfaces import ISessionDataContainer
from zope.session.interfaces import ISessionPkgData, ISessionData
@@ -32,7 +33,6 @@
from zope.session.http import CookieClientIdManager
from zope.session.bootstrap import bootStrapSubscriber as \
sessionBootstrapSubscriber
-from zope.session.testing import SessionLayer
from zope.publisher.interfaces import IRequest
from zope.publisher.http import HTTPRequest
@@ -40,14 +40,7 @@
from zope.app.appsetup.tests import TestBootstrapSubscriber, EventStub
from zope.app.appsetup.bootstrap import bootStrapSubscriber
-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
-
def setUp(session_data_container_class=PersistentSessionDataContainer):
placelesssetup.setUp()
zope.component.provideAdapter(ClientId, (IRequest,), IClientId)
@@ -101,93 +94,7 @@
-
-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())
@@ -196,8 +103,6 @@
suite.addTest(doctest.DocTestSuite('zope.session.http',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,)
)
- suite.addTest(unittest.makeSuite(ZPTSessionTest))
- suite.addTest(unittest.makeSuite(VirtualHostSessionTest))
return suite
More information about the Checkins
mailing list