Commit 3b76998d authored by Jérome Perrin's avatar Jérome Perrin

method_id= in clearCache is not part of the API.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11122 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 224f9899
...@@ -370,33 +370,23 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -370,33 +370,23 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_06_CachingMethod(self, quiet=quiet, run=run_all_test): def test_06_CachingMethod(self, quiet=quiet, run=run_all_test):
"""Tests Caching methods.""" """Tests Caching methods."""
if not run: return if not run: return
cached_var1 = cached_var1_orig = 'cached_var1' cached_var = cached_var_orig = 'cached_var1'
cached_var2 = cached_var2_orig = 'cached_var2'
def _cache1(): def _cache():
return cached_var1 return cached_var
def _cache2():
return cached_var2
from Products.ERP5Type.Cache import CachingMethod, clearCache from Products.ERP5Type.Cache import CachingMethod, clearCache
cache1 = CachingMethod(_cache1, id='_cache1') cache1 = CachingMethod(_cache, id='testing_cache')
cache2 = CachingMethod(_cache2, id='_cache2')
self.assertEquals(cache1(), cached_var1) self.assertEquals(cache(), cached_var)
self.assertEquals(cache2(), cached_var2)
cached_var1 = 'cached_var1 (modified)' # change the variable
cached_var2 = 'cached_var2 (modified)' cached_var = 'cached_var (modified)'
self.assertEquals(cache1(), cached_var1_orig) # cache hit -> still the old variable
self.assertEquals(cache(), cached_var_orig)
# clearCache with a method argument only clear this cache
clearCache(method_id = '_cache1')
self.assertEquals(cache1(), cached_var1)
self.assertEquals(cache2(), cached_var2_orig)
# clearCache with no arguments clear all caches
clearCache() clearCache()
self.assertEquals(cache2(), cached_var2) self.assertEquals(cache(), cached_var)
def test_07_afterCloneScript(self, quiet=quiet, run=run_all_test): def test_07_afterCloneScript(self, quiet=quiet, run=run_all_test):
"""manage_afterClone can call a type based script.""" """manage_afterClone can call a type based script."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment