[CMF-checkins] CVS: CMF/CMFCore/tests - test_CachingPolicyManager.py:1.1.2.2 test_FSPageTemplate.py:1.2.2.1 test_all.py:1.14.2.1
Tres Seaver
tseaver@zope.com
Wed, 20 Feb 2002 11:34:31 -0500
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv28591/tests
Modified Files:
Tag: tseaver-caching_tool-branch
test_CachingPolicyManager.py test_FSPageTemplate.py
test_all.py
Log Message:
- Integrate with FSPageTemplate.
- Fix interface, and test conformance.
=== CMF/CMFCore/tests/test_CachingPolicyManager.py 1.1.2.1 => 1.1.2.2 ===
return CachingPolicyManager()
+ def test_interface( self ):
+ from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
+ from Products.CMFCore.interfaces.CachingPolicyManager \
+ import CachingPolicyManager as ICachingPolicyManager
+
+ from Interface import verify_class_implementation
+
+ verify_class_implementation( ICachingPolicyManager
+ , CachingPolicyManager )
+
def test_empty( self ):
mgr = self._makeOne()
self.assertEqual( len( mgr.listPolicies() ), 0 )
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={}
)
@@ -221,8 +230,7 @@
mgr = self._makeOne()
mgr._addPolicy( 'first', 'python:1', None, 0, 0, 0, 0 )
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={}
)
@@ -273,8 +281,7 @@
def test_lookupNoMatch( self ):
mgr = self._makeOneWithPolicies()
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={}
)
@@ -283,8 +290,7 @@
def test_lookupMatchFoo( self ):
mgr = self._makeOneWithPolicies()
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={ 'foo' : 1 }
)
@@ -296,8 +302,7 @@
def test_lookupMatchBar( self ):
mgr = self._makeOneWithPolicies()
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={ 'bar' : 1 }
)
@@ -313,8 +318,7 @@
def test_lookupMatchBaz( self ):
mgr = self._makeOneWithPolicies()
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={ 'baz' : 1 }
)
@@ -330,8 +334,7 @@
def test_lookupMatchQux( self ):
mgr = self._makeOneWithPolicies()
- headers = mgr.getHTTPCachingHeaders( REQUEST={}
- , content=DummyContent()
+ headers = mgr.getHTTPCachingHeaders( content=DummyContent()
, view_method='foo_view'
, keywords={ 'qux' : 1 }
)
=== CMF/CMFCore/tests/test_FSPageTemplate.py 1.2 => 1.2.2.1 ===
from unittest import TestCase, TestSuite, makeSuite, main
from Products.CMFCore.FSPageTemplate import FSPageTemplate
-from test_DirectoryView import skin_path_name
+from Products.CMFCore.tests.test_DirectoryView import skin_path_name
from os.path import join
from Testing.makerequest import makerequest
from Products.PageTemplates.TALES import Undefined
-class FSPageTemplateTests( TestCase ):
+from Products.CMFCore.tests.base.testcase import RequestTest
+
+class DummyCachingManager:
+ def getHTTPCachingHeaders( self, content, view_name, keywords ):
+ return ( ( 'foo', 'Foo' ), ( 'bar', 'Bar' ) )
+
+class FSPageTemplateTests( RequestTest ):
def test_Call( self ):
"""
Test calling works
"""
- root = makerequest(Zope.app())
script = FSPageTemplate('testPT', join(skin_path_name,'testPT.pt'))
- script = script.__of__(root)
+ script = script.__of__(self.root)
self.assertEqual(script(),'foo\n')
def test_BadCall( self ):
"""
Test calling a bad template gives an Undefined exception
"""
- root = makerequest(Zope.app())
script = FSPageTemplate('testPT', join(skin_path_name,'testPTbad.pt'))
- script = script.__of__(root)
+ script = script.__of__(self.root)
self.assertRaises(Undefined,script)
+
+ def test_caching( self ):
+ """
+ Test HTTP caching headers.
+ """
+ self.root.caching_policy_manager = DummyCachingManager()
+ original_len = len( self.RESPONSE.headers )
+ script = FSPageTemplate('testPT', join(skin_path_name,'testPT.pt'))
+ script = script.__of__(self.root)
+ script()
+ self.failUnless( len( self.RESPONSE.headers ) >= original_len + 2 )
+ self.failUnless( 'foo' in self.RESPONSE.headers.keys() )
+ self.failUnless( 'bar' in self.RESPONSE.headers.keys() )
def test_suite():
return TestSuite((
=== CMF/CMFCore/tests/test_all.py 1.14 => 1.14.2.1 ===
'test_DirectoryView',
'test_FSPythonScript',
- 'test_FSPageTemplate'
+ 'test_FSPageTemplate',
+ 'test_CachingPolicyManager',
])
if __name__ == '__main__':