Commit 9289ab45 authored by Nicolas Delaby's avatar Nicolas Delaby

Check that headers are well setting up by caching policy manager

for extensible contents of OOoDocument in web_mode.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36242 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ff18af4f
......@@ -28,15 +28,26 @@
##############################################################################
import unittest
import os
import transaction
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg',)
def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_data', name)
def makeFileUpload(name, as_name=None):
if as_name is None:
as_name = name
path = makeFilePath(name)
return FileUpload(path, as_name)
class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
"""Test for erp5_web business template.
"""
......@@ -70,10 +81,20 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self):
self.login()
portal = self.getPortal()
self.setDefaultSitePreference()
self.web_page_module = self.portal.web_page_module
self.web_site_module = self.portal.web_site_module
self.portal_id = self.portal.getId()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def clearModule(self, module):
module.manage_delObjects(list(module.objectIds()))
transaction.commit()
......@@ -414,6 +435,31 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
modification_date = rfc1123_date(document.getModificationDate())
self.assertEqual(modification_date, last_modified_header)
# Upload a presentation with 3 pages.
upload_file = makeFileUpload('P-DMS-Presentation.3.Pages-001-en.odp')
document = document_module.newContent(portal_type='Presentation',
file=upload_file)
reference = 'P-DMS-Presentation.3.Pages'
document.edit(reference=reference)
document.publish()
transaction.commit()
self.tic()
website_url = website.absolute_url_path()
# Check we can access to the 3 drawings converted into images.
# Those images can be accessible through extensible content
# url : path-of-document + '/' + 'img' + page-index + '.png'
for i in range(3):
path = '/'.join((website_url,
reference,
'img%s.png' % i))
response = self.publish(path)
policy_list = self.portal.caching_policy_manager.listPolicies()
policy = [policy for policy in policy_list\
if policy[0] == 'unauthenticated'][0]
self.assertEquals(response.getHeader('Content-Type'), 'image/png')
self.assertEquals(response.getHeader('Cache-Control'),
'max-age=%s' % policy[1].getMaxAgeSecs())
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5WebWithDms))
......
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