Commit 3fe528c8 authored by Nicolas Delaby's avatar Nicolas Delaby

Split Caching Policy Manager test to dedicated test suite for Text document handling.

approved by Romain


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31959 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5164d725
...@@ -1182,9 +1182,8 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1182,9 +1182,8 @@ Hé Hé Hé!""", page.asText().strip())
def test_15_Check_LastModified_Header(self): def test_15_Check_LastModified_Header(self):
"""Checks that Last-Modified header set by caching policy manager """Checks that Last-Modified header set by caching policy manager
is correctly filled with getModificationDate of content. is correctly filled with getModificationDate of content.
This test check all Policy installed by erp5_web: This test check 2 Policy installed by erp5_web:
Policy ID - unauthenticated web pages Policy ID - unauthenticated web pages
unauthenticated
authenticated authenticated
""" """
request = self.portal.REQUEST request = self.portal.REQUEST
...@@ -1217,24 +1216,6 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1217,24 +1216,6 @@ Hé Hé Hé!""", page.asText().strip())
response = self.publish(path, 'webmaster:webmaster') response = self.publish(path, 'webmaster:webmaster')
last_modified_header = response.getHeader('Last-Modified') last_modified_header = response.getHeader('Last-Modified')
self.assertTrue(last_modified_header) self.assertTrue(last_modified_header)
from App.Common import rfc1123_date
# Convert the Date into string according RFC 1123 Time Format
modification_date = rfc1123_date(document.getModificationDate())
self.assertEqual(modification_date, last_modified_header)
# unauthenticated
document_portal_type = 'Text'
document_module = self.portal.getDefaultModule(document_portal_type)
document = document_module.newContent(portal_type=document_portal_type,
reference='NXD-Document-TEXT.Cache')
document.publish()
transaction.commit()
self.tic()
path = website.absolute_url_path() + '/NXD-Document-TEXT.Cache'
response = self.publish(path)
last_modified_header = response.getHeader('Last-Modified')
self.assertTrue(last_modified_header)
from App.Common import rfc1123_date
# Convert the Date into string according RFC 1123 Time Format # Convert the Date into string according RFC 1123 Time Format
modification_date = rfc1123_date(document.getModificationDate()) modification_date = rfc1123_date(document.getModificationDate())
self.assertEqual(modification_date, last_modified_header) self.assertEqual(modification_date, last_modified_header)
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -386,6 +387,33 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -386,6 +387,33 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
field.get_value('form_id'), field.get_value('form_id'),
field.get_value('field_id'))) field.get_value('field_id')))
def test_06_Check_LastModified_Header(self):
"""Checks that Last-Modified header set by caching policy manager
is correctly filled with getModificationDate of content.
This test check "unauthenticated" Policy installed by erp5_web:
"""
request = self.portal.REQUEST
website = self.setupWebSite()
web_section_portal_type = 'Web Section'
web_section = website.newContent(portal_type=web_section_portal_type)
# unauthenticated
document_portal_type = 'Text'
document_module = self.portal.getDefaultModule(document_portal_type)
document = document_module.newContent(portal_type=document_portal_type,
reference='NXD-Document-TEXT.Cache')
document.publish()
transaction.commit()
self.tic()
path = website.absolute_url_path() + '/NXD-Document-TEXT.Cache'
response = self.publish(path)
last_modified_header = response.getHeader('Last-Modified')
self.assertTrue(last_modified_header)
from App.Common import rfc1123_date
# Convert the Date into string according RFC 1123 Time Format
modification_date = rfc1123_date(document.getModificationDate())
self.assertEqual(modification_date, last_modified_header)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5WebWithDms)) 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