Permalink
Browse files

test_cache_with_GZIP_anonymous does fail now, reproducing the https:/…

  • Loading branch information...
1 parent f3325aa commit ea90c996ff83b55d2d4e9fbb490bbe99020a4466 @ebrehault ebrehault committed Nov 13, 2012
Showing with 52 additions and 16 deletions.
  1. +3 −0 src/plone/app/theming/testing.py
  2. +49 −16 src/plone/app/theming/tests/test_caching.py
View
3 src/plone/app/theming/testing.py
@@ -6,6 +6,7 @@
from plone.app.testing.layers import IntegrationTesting
from plone.app.testing.layers import FunctionalTesting
+
class Theming(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
@@ -22,6 +23,7 @@ def setUpPloneSite(self, portal):
# install into the Plone site
applyProfile(portal, 'plone.app.theming:default')
+
class ThemingWithCaching(Theming):
defaultBases = (PLONE_FIXTURE,)
@@ -40,6 +42,7 @@ def setUpPloneSite(self, portal):
# install into the Plone site
applyProfile(portal, 'plone.app.caching:default')
applyProfile(portal, 'plone.app.theming:default')
+ portal['portal_workflow'].setDefaultChain('simple_publication_workflow')
THEMING_FIXTURE = Theming()
THEMING_INTEGRATION_TESTING = IntegrationTesting(bases=(THEMING_FIXTURE,), name="Theming:Integration")
View
65 src/plone/app/theming/tests/test_caching.py
@@ -1,13 +1,14 @@
import unittest2 as unittest
from plone.testing.z2 import Browser
-from plone.app.testing import applyProfile
+from plone.app.testing import applyProfile, setRoles
from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD
import Globals
import cStringIO
import gzip
from zope.component import provideUtility, provideAdapter, getUtility
+from zope.globalrequest import setRequest
from plone.registry.interfaces import IRegistry
from plone.registry import Registry
@@ -24,7 +25,7 @@ class TestIntegration(unittest.TestCase):
def setUp(self):
self.settings = getUtility(IRegistry).forInterface(IThemeSettings)
- self.settings.enabled = False
+ self.settings.enabled = True
self.settings.rules = u'python://plone.app.theming/tests/rules.xml'
self.settings.parameterExpressions = {
'stringParam': 'string:string param value',
@@ -33,30 +34,46 @@ def setUp(self):
'requestParam': 'request/useother | string:off',
}
- portal = self.layer['portal']
- applyProfile(portal, 'plone.app.caching:without-caching-proxy')
+ self.portal = self.layer['portal']
+ setRequest(self.portal.REQUEST)
+
+ applyProfile(self.portal, 'plone.app.caching:without-caching-proxy')
self.cacheSettings = getUtility(IRegistry).forInterface(ICacheSettings)
self.cacheSettings.enabled = True
+ self.cacheSettings.operationMapping = {'plone.content.folderView': 'plone.app.caching.weakCaching'}
+ registry = getUtility(IRegistry)
+ registry['plone.app.caching.weakCaching.ramCache'] = True
import transaction;
transaction.commit()
+ def tearDown(self):
+ setRequest(None)
+
def test_cache_without_GZIP(self):
ploneSettings = getUtility(IRegistry).forInterface(IPloneCacheSettings)
ploneSettings.enableCompression = False
app = self.layer['app']
portal = self.layer['portal']
- self.settings.enabled = True
- import transaction; transaction.commit()
+ # Folder content
+ setRoles(portal, TEST_USER_ID, ('Manager',))
+ portal.invokeFactory('Folder', 'f1')
+ portal['f1'].setTitle(u"Folder one")
+ portal['f1'].setDescription(u"Folder one description")
+ portal['f1'].reindexObject()
+ # Publish the folder
+ portal.portal_workflow.doActionFor(portal['f1'], 'publish')
+
+ import transaction; transaction.commit()
browser = Browser(app)
- browser.open(portal.absolute_url())
+ browser.open(portal['f1'].absolute_url())
# Title - pulled in with rules.xml
- self.assertTrue(portal.title in browser.contents)
+ self.assertTrue(portal['f1'].Title() in browser.contents)
# Elsewhere - not pulled in
self.assertFalse("Accessibility" in browser.contents)
@@ -71,17 +88,25 @@ def test_cache_with_GZIP_anonymous(self):
app = self.layer['app']
portal = self.layer['portal']
- self.settings.enabled = True
- import transaction; transaction.commit()
+ # Folder content
+ setRoles(portal, TEST_USER_ID, ('Manager',))
+ portal.invokeFactory('Folder', 'f2')
+ portal['f2'].setTitle(u"Folder two")
+ portal['f2'].setDescription(u"Folder two description")
+ portal['f2'].reindexObject()
+ # Publish the folder
+ portal.portal_workflow.doActionFor(portal['f2'], 'publish')
+
+ import transaction; transaction.commit()
browser = Browser(app)
browser.addHeader('Accept-Encoding', 'gzip')
- browser.open(portal.absolute_url())
+ browser.open(portal['f2'].absolute_url())
content_handler = cStringIO.StringIO(browser.contents)
uncompressed = gzip.GzipFile(fileobj=content_handler).read()
# Title - pulled in with rules.xml
- self.assertTrue(portal.title in uncompressed)
+ self.assertTrue(portal['f2'].Title() in uncompressed)
# Elsewhere - not pulled in
self.assertFalse("Accessibility" in uncompressed)
@@ -100,19 +125,27 @@ def test_cache_with_GZIP_authenticated(self):
app = self.layer['app']
portal = self.layer['portal']
- self.settings.enabled = True
- import transaction; transaction.commit()
+ # Folder content
+ setRoles(portal, TEST_USER_ID, ('Manager',))
+ portal.invokeFactory('Folder', 'f3')
+ portal['f3'].setTitle(u"Folder three")
+ portal['f3'].setDescription(u"Folder three description")
+ portal['f3'].reindexObject()
+ # Publish the folder
+ portal.portal_workflow.doActionFor(portal['f3'], 'publish')
+
+ import transaction; transaction.commit()
browser = Browser(app)
browser.addHeader('Accept-Encoding', 'gzip')
browser.addHeader('Authorization', 'Basic %s:%s' %
(TEST_USER_NAME, TEST_USER_PASSWORD,))
- browser.open(portal.absolute_url())
+ browser.open(portal['f3'].absolute_url())
content_handler = cStringIO.StringIO(browser.contents)
uncompressed = gzip.GzipFile(fileobj=content_handler).read()
# Title - pulled in with rules.xml
- self.assertTrue(portal.title in uncompressed)
+ self.assertTrue(portal['f3'].Title() in uncompressed)
# Elsewhere - not pulled in
self.assertFalse("Accessibility" in uncompressed)

0 comments on commit ea90c99

Please sign in to comment.