Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
CMFCore.tests.test_CachingPolicyManager.CachingPolicyTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_z3interfaces
def test_empty
def test_noPassPredicate
def test_typePredicate
def test_typePredicateMiss
def test_viewPredicate
def test_viewPredicateMiss
def test_kwPredicate
def test_kwPredicateMiss
def test_mtimeFunc
def test_mtimeFuncNone
def test_maxAge
def test_sMaxAge
def test_noCache
def test_noStore
def test_mustRevalidate
def test_proxyRevalidate
def test_public
def test_private
def test_noTransform
def test_lastModified
def test_preCheck
def test_postCheck
def test_ETag
def test_combined

Static Public Attributes

 layer = TraversingZCMLLayer

Private Member Functions

def _makePolicy
def _makeContext

Private Attributes

 _epoch

Detailed Description

Definition at line 91 of file test_CachingPolicyManager.py.


Member Function Documentation

Definition at line 100 of file test_CachingPolicyManager.py.

00100 
00101     def _makeContext( self, **kw ):
00102         from Products.CMFCore.CachingPolicyManager import createCPContext
00103         return createCPContext( DummyContent2(self._epoch)
00104                               , 'foo_view', kw, self._epoch )

Here is the call graph for this function:

def CMFCore.tests.test_CachingPolicyManager.CachingPolicyTests._makePolicy (   self,
  policy_id,
  kw 
) [private]

Definition at line 95 of file test_CachingPolicyManager.py.

00095 
00096     def _makePolicy( self, policy_id, **kw ):
00097         from Products.CMFCore.CachingPolicyManager import CachingPolicy
00098 
00099         return CachingPolicy( policy_id, **kw )

Here is the caller graph for this function:

Definition at line 105 of file test_CachingPolicyManager.py.

00105 
00106     def setUp(self):
00107         self._epoch = DateTime(0)

Definition at line 410 of file test_CachingPolicyManager.py.

00410 
00411     def test_combined( self ):
00412 
00413         policy = self._makePolicy( 'noStore', no_cache=1, no_store=1 )
00414         context = self._makeContext()
00415         headers = policy.getHeaders( context )
00416 
00417         self.assertEqual( len( headers ), 3 )
00418         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00419         self.assertEqual( headers[0][1]
00420                         , rfc1123_date(self._epoch.timeTime()) )
00421         self.assertEqual( headers[1][0].lower() , 'pragma' )
00422         self.assertEqual( headers[1][1] , 'no-cache' )
00423         self.assertEqual( headers[2][0].lower() , 'cache-control' )
00424         self.assertEqual( headers[2][1] , 'no-cache, no-store' )
00425 

Here is the call graph for this function:

Definition at line 115 of file test_CachingPolicyManager.py.

00115 
00116     def test_empty( self ):
00117         policy = self._makePolicy( 'empty' )
00118         context = self._makeContext()
00119         headers = policy.getHeaders( context )
00120 
00121         self.assertEqual( len( headers ), 1 )
00122         self.assertEqual( headers[0][0], 'Last-modified' )
00123         self.assertEqual( headers[0][1]
00124                         , rfc1123_date(self._epoch.timeTime()) )

Here is the call graph for this function:

Definition at line 387 of file test_CachingPolicyManager.py.

00387 
00388     def test_ETag( self ):
00389 
00390         # With an empty etag_func, no ETag should be produced
00391         policy = self._makePolicy( 'ETag', etag_func='' )
00392         context = self._makeContext()
00393         headers = policy.getHeaders( context )
00394 
00395         self.assertEqual( len( headers ), 1)
00396         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00397         self.assertEqual( headers[0][1]
00398                         , rfc1123_date(self._epoch.timeTime()) )
00399 
00400         policy = self._makePolicy( 'ETag', etag_func='string:foo' )
00401         context = self._makeContext()
00402         headers = policy.getHeaders( context )
00403 
00404         self.assertEqual( len( headers ), 2)
00405         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00406         self.assertEqual( headers[0][1]
00407                         , rfc1123_date(self._epoch.timeTime()) )
00408         self.assertEqual( headers[1][0].lower(), 'etag' )
00409         self.assertEqual( headers[1][1], 'foo' )

Here is the call graph for this function:

Definition at line 174 of file test_CachingPolicyManager.py.

00174 
00175     def test_kwPredicate( self ):
00176 
00177         policy = self._makePolicy( 'kwPredicate'
00178                                  , predicate='python:"foo" in keywords.keys()' )
00179         context = self._makeContext( foo=1 )
00180         headers = policy.getHeaders( context )
00181 
00182         self.assertEqual( len( headers ), 1 )
00183         self.assertEqual( headers[0][0], 'Last-modified' )
00184         self.assertEqual( headers[0][1]
00185                         , rfc1123_date(self._epoch.timeTime()) )

Here is the call graph for this function:

Definition at line 186 of file test_CachingPolicyManager.py.

00186 
00187     def test_kwPredicateMiss( self ):
00188 
00189         policy = self._makePolicy( 'kwPredicateMiss'
00190                                  , predicate='python:"foo" in keywords.keys()' )
00191         context = self._makeContext( bar=1 )
00192         headers = policy.getHeaders( context )
00193 
00194         self.assertEqual( len( headers ), 0 )
00195 
00196         context = self._makeContext()
00197         headers = policy.getHeaders( context )
00198 
00199         self.assertEqual( len( headers ), 0 )

Here is the call graph for this function:

Definition at line 348 of file test_CachingPolicyManager.py.

00348 
00349     def test_lastModified( self ):
00350 
00351         policy = self._makePolicy( 'lastModified', last_modified=0 )
00352         context = self._makeContext()
00353         headers = policy.getHeaders( context )
00354 
00355         self.assertEqual( len( headers ), 0 )
00356         self.assertEqual(policy.getLastModified(), 0)

Here is the call graph for this function:

Definition at line 221 of file test_CachingPolicyManager.py.

00221 
00222     def test_maxAge( self ):
00223 
00224         policy = self._makePolicy( 'aged', max_age_secs=86400 )
00225         context = self._makeContext()
00226         headers = policy.getHeaders( context )
00227 
00228         self.assertEqual( len( headers ), 3 )
00229         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00230         self.assertEqual( headers[0][1]
00231                         , rfc1123_date(self._epoch.timeTime()) )
00232         self.assertEqual( headers[1][0].lower() , 'expires' )
00233         self.assertEqual( headers[1][1]
00234                         , rfc1123_date((self._epoch+1).timeTime()) )
00235         self.assertEqual( headers[2][0].lower() , 'cache-control' )
00236         self.assertEqual( headers[2][1] , 'max-age=86400' )

Here is the call graph for this function:

Definition at line 200 of file test_CachingPolicyManager.py.

00200 
00201     def test_mtimeFunc( self ):
00202 
00203         policy = self._makePolicy( 'mtimeFunc'
00204                                  , mtime_func='string:2001/01/01' )
00205         context = self._makeContext()
00206         headers = policy.getHeaders( context )
00207 
00208         self.assertEqual( len( headers ), 1 )
00209         self.assertEqual( headers[0][0], 'Last-modified' )
00210         self.assertEqual( headers[0][1]
00211                         , rfc1123_date(ACCLARK.timeTime()) )

Here is the call graph for this function:

Definition at line 212 of file test_CachingPolicyManager.py.

00212 
00213     def test_mtimeFuncNone( self ):
00214 
00215         policy = self._makePolicy( 'mtimeFuncNone'
00216                                  , mtime_func='nothing' )
00217         context = self._makeContext()
00218         headers = policy.getHeaders( context )
00219 
00220         self.assertEqual( len( headers ), 0 )

Here is the call graph for this function:

Definition at line 279 of file test_CachingPolicyManager.py.

00279 
00280     def test_mustRevalidate( self ):
00281 
00282         policy = self._makePolicy( 'mustRevalidate', must_revalidate=1 )
00283         context = self._makeContext()
00284         headers = policy.getHeaders( context )
00285 
00286         self.assertEqual( len( headers ), 2 )
00287         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00288         self.assertEqual( headers[0][1]
00289                         , rfc1123_date(self._epoch.timeTime()) )
00290         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00291         self.assertEqual( headers[1][1] , 'must-revalidate' )

Here is the call graph for this function:

Definition at line 251 of file test_CachingPolicyManager.py.

00251 
00252     def test_noCache( self ):
00253 
00254         policy = self._makePolicy( 'noCache', no_cache=1 )
00255         context = self._makeContext()
00256         headers = policy.getHeaders( context )
00257 
00258         self.assertEqual( len( headers ), 3 )
00259         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00260         self.assertEqual( headers[0][1]
00261                         , rfc1123_date(self._epoch.timeTime()) )
00262         self.assertEqual( headers[1][0].lower() , 'pragma' )
00263         self.assertEqual( headers[1][1] , 'no-cache' )
00264         self.assertEqual( headers[2][0].lower() , 'cache-control' )
00265         self.assertEqual( headers[2][1] , 'no-cache' )

Here is the call graph for this function:

Definition at line 125 of file test_CachingPolicyManager.py.

00125 
00126     def test_noPassPredicate( self ):
00127 
00128         policy = self._makePolicy( 'noPassPredicate', predicate='nothing' )
00129         context = self._makeContext()
00130         headers = policy.getHeaders( context )
00131 
00132         self.assertEqual( len( headers ), 0 )

Here is the call graph for this function:

Definition at line 266 of file test_CachingPolicyManager.py.

00266 
00267     def test_noStore( self ):
00268 
00269         policy = self._makePolicy( 'noStore', no_store=1 )
00270         context = self._makeContext()
00271         headers = policy.getHeaders( context )
00272 
00273         self.assertEqual( len( headers ), 2 )
00274         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00275         self.assertEqual( headers[0][1]
00276                         , rfc1123_date(self._epoch.timeTime()) )
00277         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00278         self.assertEqual( headers[1][1] , 'no-store' )

Here is the call graph for this function:

Definition at line 334 of file test_CachingPolicyManager.py.

00334 
00335     def test_noTransform( self ):
00336 
00337         policy = self._makePolicy( 'noTransform', no_transform=1 )
00338         context = self._makeContext()
00339         headers = policy.getHeaders( context )
00340 
00341         self.assertEqual( len( headers ), 2 )
00342         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00343         self.assertEqual( headers[0][1]
00344                         , rfc1123_date(self._epoch.timeTime()) )
00345         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00346         self.assertEqual( headers[1][1] , 'no-transform' )
00347         self.assertEqual(policy.getNoTransform(), 1)

Here is the call graph for this function:

Definition at line 372 of file test_CachingPolicyManager.py.

00372 
00373     def test_postCheck( self ):
00374 
00375         policy = self._makePolicy( 'postCheck', post_check=1 )
00376         context = self._makeContext()
00377         headers = policy.getHeaders( context )
00378 
00379         self.assertEqual( len( headers ), 2 )
00380         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00381         self.assertEqual( headers[0][1]
00382                         , rfc1123_date(self._epoch.timeTime()) )
00383         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00384         self.assertEqual( headers[1][1] , 'post-check=1' )
00385         self.assertEqual(policy.getPostCheck(), 1)
00386         self.assertEqual(policy.getPreCheck(), None)

Here is the call graph for this function:

Definition at line 357 of file test_CachingPolicyManager.py.

00357 
00358     def test_preCheck( self ):
00359 
00360         policy = self._makePolicy( 'preCheck', pre_check=1 )
00361         context = self._makeContext()
00362         headers = policy.getHeaders( context )
00363 
00364         self.assertEqual( len( headers ), 2 )
00365         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00366         self.assertEqual( headers[0][1]
00367                         , rfc1123_date(self._epoch.timeTime()) )
00368         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00369         self.assertEqual( headers[1][1] , 'pre-check=1' )
00370         self.assertEqual(policy.getPreCheck(), 1)
00371         self.assertEqual(policy.getPostCheck(), None)

Here is the call graph for this function:

Definition at line 320 of file test_CachingPolicyManager.py.

00320 
00321     def test_private( self ):
00322 
00323         policy = self._makePolicy( 'private', private=1 )
00324         context = self._makeContext()
00325         headers = policy.getHeaders( context )
00326 
00327         self.assertEqual( len( headers ), 2 )
00328         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00329         self.assertEqual( headers[0][1]
00330                         , rfc1123_date(self._epoch.timeTime()) )
00331         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00332         self.assertEqual( headers[1][1] , 'private' )
00333         self.assertEqual(policy.getPrivate(), 1)

Here is the call graph for this function:

Definition at line 292 of file test_CachingPolicyManager.py.

00292 
00293     def test_proxyRevalidate( self ):
00294 
00295         policy = self._makePolicy( 'proxyRevalidate', proxy_revalidate=1 )
00296         context = self._makeContext()
00297         headers = policy.getHeaders( context )
00298 
00299         self.assertEqual( len( headers ), 2 )
00300         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00301         self.assertEqual( headers[0][1]
00302                         , rfc1123_date(self._epoch.timeTime()) )
00303         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00304         self.assertEqual( headers[1][1] , 'proxy-revalidate' )
00305         self.assertEqual(policy.getProxyRevalidate(), 1)

Here is the call graph for this function:

Definition at line 306 of file test_CachingPolicyManager.py.

00306 
00307     def test_public( self ):
00308 
00309         policy = self._makePolicy( 'public', public=1 )
00310         context = self._makeContext()
00311         headers = policy.getHeaders( context )
00312 
00313         self.assertEqual( len( headers ), 2 )
00314         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00315         self.assertEqual( headers[0][1]
00316                         , rfc1123_date(self._epoch.timeTime()) )
00317         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00318         self.assertEqual( headers[1][1] , 'public' )
00319         self.assertEqual(policy.getPublic(), 1)

Here is the call graph for this function:

Definition at line 237 of file test_CachingPolicyManager.py.

00237 
00238     def test_sMaxAge( self ):
00239 
00240         policy = self._makePolicy( 's_aged', s_max_age_secs=86400 )
00241         context = self._makeContext()
00242         headers = policy.getHeaders( context )
00243 
00244         self.assertEqual( len( headers ), 2 )
00245         self.assertEqual( headers[0][0].lower() , 'last-modified' )
00246         self.assertEqual( headers[0][1]
00247                         , rfc1123_date(self._epoch.timeTime()) )
00248         self.assertEqual( headers[1][0].lower() , 'cache-control' )
00249         self.assertEqual( headers[1][1] , 's-maxage=86400' )
00250         self.assertEqual(policy.getSMaxAgeSecs(), 86400)

Here is the call graph for this function:

Definition at line 133 of file test_CachingPolicyManager.py.

00133 
00134     def test_typePredicate( self ):
00135 
00136         policy = self._makePolicy( 'typePredicate'
00137                            , predicate='python:object.Type() == "Dummy"' )
00138         context = self._makeContext()
00139         headers = policy.getHeaders( context )
00140 
00141         self.assertEqual( len( headers ), 1 )
00142         self.assertEqual( headers[0][0] , 'Last-modified' )
00143         self.assertEqual( headers[0][1] , rfc1123_date(self._epoch.timeTime()) )

Here is the call graph for this function:

Definition at line 144 of file test_CachingPolicyManager.py.

00144 
00145     def test_typePredicateMiss( self ):
00146 
00147         policy = self._makePolicy( 'typePredicate'
00148                         , predicate='python:object.Type() == "Foolish"' )
00149         context = self._makeContext()
00150         headers = policy.getHeaders( context )
00151 
00152         self.assertEqual( len( headers ), 0 )

Here is the call graph for this function:

Definition at line 153 of file test_CachingPolicyManager.py.

00153 
00154     def test_viewPredicate( self ):
00155 
00156         policy = self._makePolicy( 'viewPredicate'
00157                                  , predicate='python:view == "foo_view"' )
00158         context = self._makeContext()
00159         headers = policy.getHeaders( context )
00160 
00161         self.assertEqual( len( headers ), 1 )
00162         self.assertEqual( headers[0][0], 'Last-modified' )
00163         self.assertEqual( headers[0][1]
00164                         , rfc1123_date(self._epoch.timeTime()) )

Here is the call graph for this function:

Definition at line 165 of file test_CachingPolicyManager.py.

00165 
00166     def test_viewPredicateMiss( self ):
00167 
00168         policy = self._makePolicy( 'viewPredicateMiss'
00169                            , predicate='python:view == "bar_view"' )
00170         context = self._makeContext()
00171         headers = policy.getHeaders( context )
00172 
00173         self.assertEqual( len( headers ), 0 )

Here is the call graph for this function:

Definition at line 108 of file test_CachingPolicyManager.py.

00108 
00109     def test_z3interfaces(self):
00110         from zope.interface.verify import verifyClass
00111         from Products.CMFCore.CachingPolicyManager import CachingPolicy
00112         from Products.CMFCore.interfaces import ICachingPolicy
00113 
00114         verifyClass(ICachingPolicy, CachingPolicy)


Member Data Documentation

Definition at line 106 of file test_CachingPolicyManager.py.

Definition at line 93 of file test_CachingPolicyManager.py.


The documentation for this class was generated from the following file: