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

Tres Seaver tseaver at palladion.com
Wed Jun 8 09:16:36 EDT 2005


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

Modified Files:
      Tag: CMF-1_5-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.10.14.1 => 1.10.14.2 ===
--- Products/CMFCore/tests/test_FSImage.py:1.10.14.1	Sun Nov 14 18:52:10 2004
+++ Products/CMFCore/tests/test_FSImage.py	Wed Jun  8 09:16:36 2005
@@ -124,6 +124,35 @@
         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