[Zope-CVS] CVS: Products/FileCacheManager/tests -
testFileCacheManager.py:1.9
Jens Vagelpohl
jens at dataflake.org
Thu Aug 19 15:37:33 EDT 2004
Update of /cvs-repository/Products/FileCacheManager/tests
In directory cvs.zope.org:/tmp/cvs-serv7600/tests
Modified Files:
testFileCacheManager.py
Log Message:
- add transaction awareness in two places:
* ZCacheable_set will only write a file if the transaction commits
* ZCacheable_invalidate will only delete a file if the transation commits
=== Products/FileCacheManager/tests/testFileCacheManager.py 1.8 => 1.9 ===
--- Products/FileCacheManager/tests/testFileCacheManager.py:1.8 Mon Aug 16 05:04:12 2004
+++ Products/FileCacheManager/tests/testFileCacheManager.py Thu Aug 19 15:37:31 2004
@@ -63,6 +63,7 @@
self.f1 = Dummy(id='f1', fakepath='/spam/eggs', size=30)
self.f2 = Dummy(id='f2', fakepath='/bacon', size=1000 * 1000)
self.all_files = (self.f1, self.f2)
+ get_transaction().commit()
def tearDown(self):
for root, dirs, files in os.walk(FCM_DIR, topdown=False):
@@ -101,6 +102,7 @@
# First, test against the standard non-TAL-Expression munger
for ob in self.all_files:
self.FC.ZCache_set(ob)
+ get_transaction().commit()
# don't know how to verify that it worked
# without testing the implementation.
fpath = self.FC._fileName(ob)
@@ -110,14 +112,26 @@
self.FC.setNamingExpression("python: object_url.replace('/', '_')")
for ob in self.all_files:
self.FC.ZCache_set(ob)
+ get_transaction().commit()
fpath = self.FC._fileName(ob)
self.failUnless(os.path.exists(fpath))
+
+ def testZCache_set_aborted(self):
+ # First, test against the standard non-TAL-Expression munger
+ for ob in self.all_files:
+ self.FC.ZCache_set(ob)
+ get_transaction().abort()
+ # don't know how to verify that it worked
+ # without testing the implementation.
+ fpath = self.FC._fileName(ob)
+ self.failIf(os.path.exists(fpath))
def testZCache_get(self):
""" assume that ZCache_set works :-P """
for ob in self.all_files:
self.FC.ZCache_set(ob) # assume that works.
+ get_transaction().commit()
# we should get back a filestream_iterator.
file_iter = self.FC.ZCache_get(ob)
@@ -137,11 +151,24 @@
def testZCache_invalidate(self):
for ob in self.all_files:
- self.FC.ZCache_set(ob) # assume that works
+ self.FC.ZCache_set(ob)
+ get_transaction().commit()
fpath = self.FC._fileName(ob)
self.FC.ZCache_invalidate(ob)
+ get_transaction().commit()
# the file should now be gone
self.failIf(os.path.exists(fpath))
+
+ def testZCache_invalidate_aborted(self):
+ for ob in self.all_files:
+ self.FC.ZCache_set(ob)
+ get_transaction().commit()
+ fpath = self.FC._fileName(ob)
+ self.FC.ZCache_invalidate(ob)
+ get_transaction().abort()
+ # the file should *still be there*
+ self.failUnless(os.path.exists(fpath))
+
class FileCacheManagerTestBase(unittest.TestCase):
More information about the Zope-CVS
mailing list