Commit aaeb9477 authored by Stefan H. Holek's avatar Stefan H. Holek

Fixed _refreshSkinData() helper to work with CMF >= 1.5.

parent f9f42abf
...@@ -95,11 +95,12 @@ class PortalTestCase(base.TestCase): ...@@ -95,11 +95,12 @@ class PortalTestCase(base.TestCase):
self.folder = pm.getHomeFolder(user_name) self.folder = pm.getHomeFolder(user_name)
def _refreshSkinData(self): def _refreshSkinData(self):
'''Refreshes the magic _v_skindata attribute.''' '''Refreshes the skin cache.'''
if hasattr(self.portal, '_v_skindata'): if hasattr(self.portal, 'clearCurrentSkin'):
self.portal.clearCurrentSkin()
else: # CMF 1.4
self.portal._v_skindata = None self.portal._v_skindata = None
if hasattr(self.portal, 'setupCurrentSkin'): self.portal.setupCurrentSkin()
self.portal.setupCurrentSkin()
# Portal interface # Portal interface
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
- Removed doctest.py, we now use the one from zope.testing. - Removed doctest.py, we now use the one from zope.testing.
- Removed dochttp.py + test, we now use the one from zope.app.tests. - Removed dochttp.py + test, we now use the one from zope.app.tests.
- ZopeLite now takes care not to monkey patch an already started Zope. - ZopeLite now takes care not to monkey patch an already started Zope.
- PortalTestCase no longer calls _refreshSkinData() as CMF is smart enough - PortalTestCase.setUp() no longer calls _refreshSkinData() as CMF is smart
now (and CMF 1.5+ does not work that way anyway). enough now.
- Fixed _refreshSkinData() helper to work with CMF >= 1.5.
- Fixed a bug where using sessions in sandboxed (functional) tests would cause - Fixed a bug where using sessions in sandboxed (functional) tests would cause
connection pool depletion and subsequent hangs. Thanks to Balazs Ree. connection pool depletion and subsequent hangs. Thanks to Balazs Ree.
......
...@@ -48,15 +48,16 @@ from OFS.SimpleItem import SimpleItem ...@@ -48,15 +48,16 @@ from OFS.SimpleItem import SimpleItem
from OFS.Folder import Folder from OFS.Folder import Folder
class DummyPortal(Folder): class DummyPortal(Folder):
_v_skindata = None
def __init__(self, id): def __init__(self, id):
self.id = id self.id = id
self._addRole('Member') self._addRole('Member')
self._setObject('portal_membership', DummyMembershipTool()) self._setObject('portal_membership', DummyMembershipTool())
self.manage_addFolder('Members') self.manage_addFolder('Members')
self._called = []
def clearCurrentSkin(self):
self._called.append('clearCurrentSkin')
def setupCurrentSkin(self): def setupCurrentSkin(self):
if self._v_skindata is None: self._called.append('setupCurrentSkin')
self._v_skindata = 'refreshed'
class DummyMembershipTool(SimpleItem): class DummyMembershipTool(SimpleItem):
id = 'portal_membership' id = 'portal_membership'
...@@ -148,12 +149,11 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase): ...@@ -148,12 +149,11 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self.assertEqual(owner_info, ([portal_name, 'acl_users'], user_name)) self.assertEqual(owner_info, ([portal_name, 'acl_users'], user_name))
def test_refreshSkinData(self): def test_refreshSkinData(self):
# The _v_skindata attribute should be refreshed # The skin cache should be refreshed
self.app = self._app() self.app = self._app()
self.portal = self.getPortal() self.portal = self.getPortal()
self.assertEqual(self.portal._v_skindata, None)
self._refreshSkinData() self._refreshSkinData()
self.assertEqual(self.portal._v_skindata, 'refreshed') self.assertEqual(self.portal._called, ['clearCurrentSkin', 'setupCurrentSkin'])
def test_setRoles(self): def test_setRoles(self):
# Roles should be set for user # Roles should be set for user
...@@ -320,8 +320,6 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase): ...@@ -320,8 +320,6 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
# XXX: Changed in 0.9.0 # XXX: Changed in 0.9.0
#self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp']) #self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp']) self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp'])
# XXX: Changed in 0.9.7
#self.assertEqual(self.portal._v_skindata, 'refreshed')
def test_tearDown(self): def test_tearDown(self):
# Everything should be removed # Everything should be removed
...@@ -344,8 +342,6 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase): ...@@ -344,8 +342,6 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
# XXX: Changed in 0.9.0 # XXX: Changed in 0.9.0
#self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp']) #self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp']) self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp'])
# XXX: Changed in 0.9.7
#self.assertEqual(self.portal._v_skindata, 'refreshed')
# This is crazy # This is crazy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment