From ed0b0450536dd60e480a77debc66dab8b9df9d08 Mon Sep 17 00:00:00 2001 From: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com> Date: Thu, 20 Aug 2020 13:59:03 +0200 Subject: [PATCH] testERP5WebWithDms: revert the change in Caching Policy Manager not to affect following tests. --- .../test.erp5.testERP5WebWithDms.py | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testERP5WebWithDms.py b/bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testERP5WebWithDms.py index 49b31e4893..ec80c39f8c 100644 --- a/bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testERP5WebWithDms.py +++ b/bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testERP5WebWithDms.py @@ -656,31 +656,34 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): # Those images can be accessible through extensible content # url : path-of-document + '/' + 'img' + page-index + '.png' # Update policy to have stale values - self.portal.caching_policy_manager._updatePolicy( - "unauthenticated no language", "python: member is None", - "python: getattr(object, 'getModificationDate', object.modified)()", - 1200, 30, 600, 0, 0, 0, "Accept-Language, Cookie", "", None, - 0, 1, 0, 0, 1, 1, None, None) - self.tic() - policy_list = self.portal.caching_policy_manager.listPolicies() - policy = [policy[1] for policy in policy_list\ - if policy[0] == 'unauthenticated no language'][0] - # Check policy has been updated - self.assertEquals(policy.getMaxAgeSecs(), 1200) - self.assertEquals(policy.getStaleWhileRevalidateSecs(), 30) - self.assertEquals(policy.getStaleIfErrorSecs(), 600) - for i in xrange(3): - path = '/'.join((website_url, - reference, - 'img%s.png' % i)) - response = self.publish(path) - self.assertEquals(response.getHeader('Content-Type'), 'image/png') - self.assertEquals(response.getHeader('Cache-Control'), - 'max-age=%d, stale-while-revalidate=%d, stale-if-error=%d, public' % \ - (policy.getMaxAgeSecs(), - policy.getStaleWhileRevalidateSecs(), - policy.getStaleIfErrorSecs())) - + policy_orig = self.portal.caching_policy_manager._policies['unauthenticated no language'] + try: + self.portal.caching_policy_manager._updatePolicy( + "unauthenticated no language", "python: member is None", + "python: getattr(object, 'getModificationDate', object.modified)()", + 1200, 30, 600, 0, 0, 0, "Accept-Language, Cookie", "", None, + 0, 1, 0, 0, 1, 1, None, None) + self.tic() + policy_list = self.portal.caching_policy_manager.listPolicies() + policy = [policy[1] for policy in policy_list\ + if policy[0] == 'unauthenticated no language'][0] + # Check policy has been updated + self.assertEquals(policy.getMaxAgeSecs(), 1200) + self.assertEquals(policy.getStaleWhileRevalidateSecs(), 30) + self.assertEquals(policy.getStaleIfErrorSecs(), 600) + for i in xrange(3): + path = '/'.join((website_url, + reference, + 'img%s.png' % i)) + response = self.publish(path) + self.assertEquals(response.getHeader('Content-Type'), 'image/png') + self.assertEquals(response.getHeader('Cache-Control'), + 'max-age=%d, stale-while-revalidate=%d, stale-if-error=%d, public' % \ + (policy.getMaxAgeSecs(), + policy.getStaleWhileRevalidateSecs(), + policy.getStaleIfErrorSecs())) + finally: + self.portal.caching_policy_manager._policies['unauthenticated no language'] = policy_orig def test_PreviewOOoDocumentWithEmbeddedImage(self): """Tests html preview of an OOo document with images as extensible content. -- 2.30.9