Commit fc470988 authored by Nicolas Delaby's avatar Nicolas Delaby

replace clearConversionCacheCalls with call of edit

to increase revision and force generation of a new cache key.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34886 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 14456fa4
...@@ -124,15 +124,15 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -124,15 +124,15 @@ class TestDocumentConversionCache(TestDocumentMixin):
transaction.commit() transaction.commit()
self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format))
self.assertTrue(document.getConversionSize(format=format)) self.assertTrue(document.getConversionSize(format=format))
document.clearConversionCache() document.edit(title='Foo')
transaction.commit() transaction.commit()
#Test Cache is cleared #Test Cache is cleared
for format in format_list: for format in format_list:
self.assertFalse(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertFalse(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format))
self.assertEqual(document.getConversionSize(format=format), 0) self.assertEqual(document.getConversionSize(format=format), 0)
document.clearConversionCache() document.edit(title='Bar')
transaction.commit() transaction.commit()
#Test Conversion Cache after clearConversionCache #Test Conversion Cache after editing
for format in format_list: for format in format_list:
document.convert(format=format) document.convert(format=format)
transaction.commit() transaction.commit()
...@@ -160,15 +160,15 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -160,15 +160,15 @@ class TestDocumentConversionCache(TestDocumentMixin):
transaction.commit() transaction.commit()
self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format))
self.assertTrue(document.getConversionSize(format=format)) self.assertTrue(document.getConversionSize(format=format))
document.clearConversionCache() document.edit(title='Foo')
transaction.commit() transaction.commit()
#Test Cache is cleared #Test Cache is cleared
for format in format_list: for format in format_list:
self.assertFalse(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertFalse(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format))
self.assertEqual(document.getConversionSize(format=format), 0) self.assertEqual(document.getConversionSize(format=format), 0)
document.clearConversionCache() document.edit(title='Bar')
transaction.commit() transaction.commit()
#Test Conversion Cache after clearConversionCache #Test Conversion Cache after editing
for format in format_list: for format in format_list:
document.convert(format=format) document.convert(format=format)
transaction.commit() transaction.commit()
...@@ -217,26 +217,30 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -217,26 +217,30 @@ class TestDocumentConversionCache(TestDocumentMixin):
self.tic() self.tic()
document_url = document.getRelativeUrl() document_url = document.getRelativeUrl()
document = self.portal.restrictedTraverse(document_url) document = self.portal.restrictedTraverse(document_url)
format_list = [format for format in document.getTargetFormatList() if format not in self.failed_format_list] format_list = [format for format in document.getTargetFormatList()\
if format not in self.failed_format_list]
if not format_list: if not format_list:
self.fail('Target format list is empty') self.fail('Target format list is empty')
#Test Conversion Cache #Test Conversion Cache
for format in format_list: for format in format_list:
document.convert(format=format) document.convert(format=format)
self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertTrue(document.hasConversion(format=format),
'Cache Storage failed for %s' % (format))
self.assertTrue(document.getConversionSize(format=format)) self.assertTrue(document.getConversionSize(format=format))
document.clearConversionCache() document.edit(title='Foo')
transaction.commit() transaction.commit()
#Test Cache is cleared #Test Cache is cleared
for format in format_list: for format in format_list:
self.assertFalse(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertFalse(document.hasConversion(format=format),
'Cache Storage failed for %s' % (format))
self.assertEqual(document.getConversionSize(format=format), 0) self.assertEqual(document.getConversionSize(format=format), 0)
document.clearConversionCache() document.edit(title='Bar')
transaction.commit() transaction.commit()
#Test Conversion Cache after clearConversionCache #Test Conversion Cache after editing
for format in format_list: for format in format_list:
document.convert(format=format) document.convert(format=format)
self.assertTrue(document.hasConversion(format=format), 'Cache Storage failed for %s' % (format)) self.assertTrue(document.hasConversion(format=format),
'Cache Storage failed for %s' % (format))
self.assertTrue(document.getConversionSize(format=format)) self.assertTrue(document.getConversionSize(format=format))
def test_05_checksum_conversion(self): def test_05_checksum_conversion(self):
...@@ -254,19 +258,19 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -254,19 +258,19 @@ class TestDocumentConversionCache(TestDocumentMixin):
kw = {'format': 'html'} kw = {'format': 'html'}
#Generate one conversion #Generate one conversion
document.convert(**kw) document.convert(**kw)
cache_id = document.generateCacheId(**kw) cache_id = '%s%s' % (document._getCacheKey(),
document.generateCacheId(**kw))
cache_factory = document._getCacheFactory() cache_factory = document._getCacheFactory()
for cache_plugin in cache_factory.getCachePluginList(): for cache_plugin in cache_factory.getCachePluginList():
cache_entry = cache_plugin.get(document._getCacheKey(), DEFAULT_CACHE_SCOPE) cache_entry = cache_plugin.get(cache_id, DEFAULT_CACHE_SCOPE)
value = cache_entry.getValue() md5sum, mime, data = cache_entry.getValue()
md5sum, mime, data = value.get(cache_id)
#get data from cache #get data from cache
self.assertTrue(md5sum) self.assertTrue(md5sum)
self.assertTrue(mime) self.assertTrue(mime)
self.assertTrue(data) self.assertTrue(data)
#Change md5 manually #Change md5 manualy
value.update({cache_id: ('Anything which is not md5', mime, data)}) cache_plugin.set(cache_id, DEFAULT_CACHE_SCOPE,
cache_plugin.set(document.getPath(), DEFAULT_CACHE_SCOPE, value, 0, 0) ('Anything which is not md5', mime, data), 0, 0)
self.assertRaises(KeyError, document.getConversion, format='html') self.assertRaises(KeyError, document.getConversion, format='html')
def test_06_check_md5_is_updated(self): def test_06_check_md5_is_updated(self):
......
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