[Zope-Checkins] CVS: Zope/lib/python/Products/Transience/tests - testTimeoutRelated.py:1.4 testTransientObjectContainer.py:1.3
Chris McDonough
chrism@zope.com
Sat, 17 Nov 2001 10:45:03 -0500
Update of /cvs-repository/Zope/lib/python/Products/Transience/tests
In directory cvs.zope.org:/tmp/cvs-serv23584/tests
Modified Files:
testTimeoutRelated.py testTransientObjectContainer.py
Log Message:
Minor test, documentation, and appearance changes according to some of Amos' comments.
=== Zope/lib/python/Products/Transience/tests/testTimeoutRelated.py 1.3 => 1.4 ===
sys.path.insert(0, '..')
sys.path.insert(0, '../../..')
- #os.chdir('../../..')
import ZODB # in order to get Persistence.Persistent working
from Testing import makerequest
import Acquisition
from Acquisition import aq_base
from Products.Transience.Transience import TransientObjectContainer
-from Products.Transience.Transience import WRITEGRANULARITY
import Products.Transience.Transience
from Products.PythonScripts.PythonScript import PythonScript
from ZODB.POSException import InvalidObjectReference
@@ -19,7 +17,7 @@
from ZODB.DemoStorage import DemoStorage
from OFS.Application import Application
import time, threading, whrandom
-
+WRITEGRANULARITY = 30
epoch = time.time()
stuff = {}
@@ -55,39 +53,27 @@
class TestBase(TestCase):
def setUp(self):
-
Products.Transience.Transience.time = fauxtime
-
self.app = makerequest.makerequest(_getApp())
-
timeout = self.timeout = 1
-
sm=TransientObjectContainer(
id='sm', timeout_mins=timeout, title='SessionThing',
addNotification=addNotificationTarget,
delNotification=delNotificationTarget)
-
self.app._setObject('sm', sm)
def tearDown(self):
get_transaction().abort()
- #self.app._p_jar.close()
- #self.app = None
_delApp()
del self.app
class TestLastAccessed(TestBase):
def testLastAccessed(self):
-
sdo = self.app.sm.new_or_existing('TempObject')
-
la1 = sdo.getLastAccessed()
-
fauxsleep(WRITEGRANULARITY + 1)
-
sdo = self.app.sm['TempObject']
-
- assert sdo.getLastAccessed() > la1
+ assert sdo.getLastAccessed() > la1, (sdo.getLastAccessed(), la1)
class TestNotifications(TestBase):
def testAddNotification(self):
@@ -103,8 +89,7 @@
sdo = self.app.sm.new_or_existing('TempObject')
timeout = self.timeout * 60
fauxsleep(timeout + (timeout * .33))
- try:
- sdo1 = self.app.sm['TempObject']
+ try: sdo1 = self.app.sm['TempObject']
except KeyError: pass
now = fauxtime()
k = sdo.get('endtime')
@@ -112,11 +97,9 @@
assert k <= now
def addNotificationTarget(item, context):
- #print "addNotificationTarget called for %s" % item
item['starttime'] = fauxtime()
def delNotificationTarget(item, context):
- #print "delNotificationTarget called for %s" % item
item['endtime'] = fauxtime()
def fauxtime():
=== Zope/lib/python/Products/Transience/tests/testTransientObjectContainer.py 1.2 => 1.3 ===
for x in range(10, 110):
self.t[x] = x
- fauxsleep(self.timeout)
+ fauxsleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 100, len(self.t.keys())
fauxsleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 0, len(self.t.keys())
@@ -392,9 +392,9 @@
self.t._reset()
for x in range(10, 110):
self.t[x] = x
- fauxsleep(self.timeout)
+ fauxsleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 100, len(self.t.keys())
- fauxsleep(self.timeout)
+ fauxsleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 100, len(self.t.keys())
fauxsleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 0, len(self.t.keys())