[Zope] Help writing test where bobobase_modification_time changes

Peter Bengtsson peter at fry-it.com
Tue Apr 8 14:08:27 EDT 2008


I'll try to explain as briefly as possible.
I've got a working cache pattern that keeps a cached version of a Zope
file's content and only when it changes (by >
bobobase_modification_time) the cache is invalidated and recreated.
Here's the gist of my test

class Test(ZopeTestCase.FunctionalTestCase):

    def test_recreateCache(self):
         """ bla """
         self.folder.manage_addFile('foo.js','FOO data')
         url = self.folder.mytool.cacheFile('foo.js') # pseudo code this time
         path = urlparse(url)[2]
         response = self.publish(path)
         self.assert... tests on response...

         _file = getattr(self.folder, 'foo.js')
         _file.manage_edit(_file.title, _file.content_type,
                          filedata='new data')

         newurl = self.folder.mytool.cacheFile('foo.js')
         assert newurl != url, "url hasn't changed :("

The reason it fails on the last line is that the time difference
between the first time and the second time is nil. Adding a
time.sleep(1) won't change anything because the
bobobase_modification_time() doesn't change.

How can I solve this? Make one big transaction two without having to
use transaction.get().commit() which I don't think I can use in unit
tests as per Dieter's advice.

Grateful for help.
Peter


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com


More information about the Zope mailing list