[CMF-checkins] CVS: Products/CMFCore/tests - test_FSImage.py:1.7.14.4

Tres Seaver tseaver at palladion.com
Wed Jun 8 09:15:50 EDT 2005


Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv12605/CMFCore/tests

Modified Files:
      Tag: CMF-1_4-branch
	test_FSImage.py 
Log Message:


  - Set cache headers in 304 responses from FSImage / FSFile
    (http://zope.org/Collectors/355)


=== Products/CMFCore/tests/test_FSImage.py 1.7.14.3 => 1.7.14.4 ===
--- Products/CMFCore/tests/test_FSImage.py:1.7.14.3	Sun Nov 14 18:15:06 2004
+++ Products/CMFCore/tests/test_FSImage.py	Wed Jun  8 09:15:49 2005
@@ -128,6 +128,35 @@
         self.failUnless('bar' in headers.keys())
         self.assertEqual(headers['test_path'], '/test_image')
 
+    def test_index_html_with_304_and_caching( self ):
+
+        # See collector #355
+        self.root.caching_policy_manager = DummyCachingManager()
+        original_len = len(self.RESPONSE.headers)
+        path, ref = self._extractFile()
+
+        import os
+        from webdav.common import rfc1123_date
+
+        mod_time = os.stat( path )[ 8 ]
+
+        image = self._makeOne( 'test_image', 'test_image.gif' )
+        image = image.__of__( self.root )
+
+        self.REQUEST.environ[ 'IF_MODIFIED_SINCE'
+                            ] = '%s;' % rfc1123_date( mod_time+3600 )
+
+        data = image.index_html( self.REQUEST, self.RESPONSE )
+
+        self.assertEqual( data, '' )
+        self.assertEqual( self.RESPONSE.getStatus(), 304 )
+
+        headers = self.RESPONSE.headers
+        self.failUnless(len(headers) >= original_len + 3)
+        self.failUnless('foo' in headers.keys())
+        self.failUnless('bar' in headers.keys())
+        self.assertEqual(headers['test_path'], '/test_image')
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(FSImageTests),



More information about the CMF-checkins mailing list