Commit 027a1fde authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_web: fix test related to caching policies

parent c95eacfe
...@@ -434,6 +434,8 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -434,6 +434,8 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
document = document_module.newContent(portal_type=document_portal_type, document = document_module.newContent(portal_type=document_portal_type,
reference='NXD-Document-TEXT.Cache') reference='NXD-Document-TEXT.Cache')
document.publish() document.publish()
# Evaluation of last modification date for the site is cached
self.portal.portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
self.tic() self.tic()
response = self.publish(website_url + '/NXD-Document-TEXT.Cache') response = self.publish(website_url + '/NXD-Document-TEXT.Cache')
last_modified_header = response.getHeader('Last-Modified') last_modified_header = response.getHeader('Last-Modified')
...@@ -450,13 +452,14 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -450,13 +452,14 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
reference = 'P-DMS-Presentation.3.Pages' reference = 'P-DMS-Presentation.3.Pages'
document.edit(reference=reference) document.edit(reference=reference)
document.publish() document.publish()
self.portal.portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
self.tic() self.tic()
# Check we can access to the 3 drawings converted into images. # Check we can access to the 3 drawings converted into images.
# Those images can be accessible through extensible content # Those images can be accessible through extensible content
# url : path-of-document + '/' + 'img' + page-index + '.png' # url : path-of-document + '/' + 'img' + page-index + '.png'
policy_list = self.portal.caching_policy_manager.listPolicies() policy_list = self.portal.caching_policy_manager.listPolicies()
policy = [policy[1] for policy in policy_list\ policy = [policy[1] for policy in policy_list\
if policy[0] == 'unauthenticated'][0] if policy[0] == 'unauthenticated no language'][0]
for i in xrange(3): for i in xrange(3):
path = '/'.join((website_url, path = '/'.join((website_url,
reference, reference,
...@@ -464,10 +467,15 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -464,10 +467,15 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
response = self.publish(path) response = self.publish(path)
policy_list = self.portal.caching_policy_manager.listPolicies() policy_list = self.portal.caching_policy_manager.listPolicies()
policy = [policy for policy in policy_list\ policy = [policy for policy in policy_list\
if policy[0] == 'unauthenticated'][0] if policy[0] == 'unauthenticated no language'][0]
self.assertEquals(response.getHeader('Content-Type'), 'image/png') self.assertEquals(response.getHeader('Content-Type'), 'image/png')
self.assertEquals(response.getHeader('Cache-Control'), self.assertEquals(
'max-age=%s, public' % policy[1].getMaxAgeSecs()) response.getHeader('Cache-Control'),
'max-age=%s, stale-while-revalidate=%s, public' % (
policy[1].getMaxAgeSecs(),
policy[1].getStaleWhileRevalidateSecs(),
)
)
def test_07_TestDocumentViewBehaviour(self): def test_07_TestDocumentViewBehaviour(self):
"""All Documents shared the same downloading behaviour """All Documents shared the same downloading behaviour
...@@ -590,6 +598,8 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -590,6 +598,8 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
document = document_module.newContent(portal_type=document_portal_type, document = document_module.newContent(portal_type=document_portal_type,
reference='NXD-Document-1-TEXT.Cache') reference='NXD-Document-1-TEXT.Cache')
document.publish() document.publish()
# Evaluation of last modification date for the site is cached
self.portal.portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
self.tic() self.tic()
response = self.publish(website_url + '/NXD-Document-1-TEXT.Cache') response = self.publish(website_url + '/NXD-Document-1-TEXT.Cache')
last_modified_header = response.getHeader('Last-Modified') last_modified_header = response.getHeader('Last-Modified')
...@@ -606,20 +616,21 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -606,20 +616,21 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
reference = 'P-DMS-Presentation-001-.3.Pages' reference = 'P-DMS-Presentation-001-.3.Pages'
document.edit(reference=reference) document.edit(reference=reference)
document.publish() document.publish()
self.portal.portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
self.tic() self.tic()
# Check we can access to the 3 drawings converted into images. # Check we can access to the 3 drawings converted into images.
# Those images can be accessible through extensible content # Those images can be accessible through extensible content
# url : path-of-document + '/' + 'img' + page-index + '.png' # url : path-of-document + '/' + 'img' + page-index + '.png'
# Update policy to have stale values # Update policy to have stale values
self.portal.caching_policy_manager._updatePolicy( self.portal.caching_policy_manager._updatePolicy(
"unauthenticated", "python: member is None", "unauthenticated no language", "python: member is None",
"python: getattr(object, 'getModificationDate', object.modified)()", "python: getattr(object, 'getModificationDate', object.modified)()",
1200, 30, 600, 0, 0, 0, "Accept-Language, Cookie", "", None, 1200, 30, 600, 0, 0, 0, "Accept-Language, Cookie", "", None,
0, 1, 0, 0, 1, 1, None, None) 0, 1, 0, 0, 1, 1, None, None)
self.tic() self.tic()
policy_list = self.portal.caching_policy_manager.listPolicies() policy_list = self.portal.caching_policy_manager.listPolicies()
policy = [policy[1] for policy in policy_list\ policy = [policy[1] for policy in policy_list\
if policy[0] == 'unauthenticated'][0] if policy[0] == 'unauthenticated no language'][0]
# Check policy has been updated # Check policy has been updated
self.assertEquals(policy.getMaxAgeSecs(), 1200) self.assertEquals(policy.getMaxAgeSecs(), 1200)
self.assertEquals(policy.getStaleWhileRevalidateSecs(), 30) self.assertEquals(policy.getStaleWhileRevalidateSecs(), 30)
......
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