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

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


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

Modified Files:
	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.11 => 1.12 ===
--- Products/CMFCore/tests/test_FSImage.py:1.11	Sun Nov 14 18:58:30 2004
+++ Products/CMFCore/tests/test_FSImage.py	Wed Jun  8 09:17:15 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