def test_setLastAccessed(self):
     t = self.t.new('xyzzy')
     ft = fauxtime.time()
     assert t.getLastAccessed() <= ft
     fauxtime.sleep(self.timeout)   # go to sleep past the granuarity
     ft2 = fauxtime.time()
     t.setLastAccessed()
     ft3 = fauxtime.time()
     assert t.getLastAccessed() <= ft3
     assert t.getLastAccessed() >= ft2
Beispiel #2
0
 def testDelNotification(self):
     self.app.sm.setDelNotificationTarget(delNotificationTarget)
     sdo = self.app.sm.new_or_existing('TempObject')
     # sleep longer than timeout
     fauxtime.sleep(self.timeout * 100.0)
     self.app.sm.get('TempObject')
     now = fauxtime.time()
     k = sdo.get('endtime')
     self.assertEqual(type(k), type(now))
     self.assert_(k <= now)
Beispiel #3
0
 def test_setLastAccessed(self):
     t = self.t.new('xyzzy')
     ft = fauxtime.time()
     self.assert_(t.getLastAccessed() <= ft)
     fauxtime.sleep(self.timeout)  # go to sleep past the granuarity
     ft2 = fauxtime.time()
     t.setLastAccessed()
     ft3 = fauxtime.time()
     self.assert_(t.getLastAccessed() <= ft3)
     self.assert_(t.getLastAccessed() >= ft2)
 def test_setLastAccessed(self):
     t = self.t.new('xyzzy')
     ft = fauxtime.time()
     self.assert_(t.getLastAccessed() <= ft)
     fauxtime.sleep(self.timeout * 2)   # go to sleep past the granularity
     ft2 = fauxtime.time()
     t.setLastAccessed()
     ft3 = fauxtime.time()
     self.assert_(t.getLastAccessed() <= ft3)
     self.assert_(t.getLastAccessed() >= ft2)
 def testDelNotification(self):
     self.app.sm.setDelNotificationTarget(delNotificationTarget)
     sdo = self.app.sm.new_or_existing('TempObject')
     # sleep longer than timeout
     fauxtime.sleep(self.timeout * 100.0)
     self.app.sm.get('TempObject')
     now = fauxtime.time()
     k = sdo.get('endtime')
     self.assertEqual(type(k), type(now))
     self.assert_(k <= now)
Beispiel #6
0
 def testDelNotification(self):
     self.app.sm.setDelNotificationTarget(delNotificationTarget)
     sdo = self.app.sm.new_or_existing('TempObject')
     timeout = self.timeout * 60
     # sleep 2X longer than timeout?  doesnt work at 1.1X, 1.5X?
     fauxtime.sleep(timeout * 2) 
     sdo1 = self.app.sm.get('TempObject')
     now = fauxtime.time()
     k = sdo.get('endtime')
     self.assertEqual(type(k), type(now))
     self.assert_(k <= now)
 def testDelNotification(self):
     self.app.sm.setDelNotificationTarget(delNotificationTarget)
     sdo = self.app.sm.new_or_existing('TempObject')
     timeout = self.timeout * 60
     fauxtime.sleep(timeout + (timeout * .75))
     sdo1 = self.app.sm.get('TempObject')
     # force the sdm to do housekeeping
     self.app.sm._housekeep(self.app.sm._deindex_next() -
                                self.app.sm._period)
     now = fauxtime.time()
     k = sdo.get('endtime')
     assert (type(k) == type(now)), type(k)
     assert k <= now, (k, now)
Beispiel #8
0
 def testLastAccessed(self):
     sdo = self.app.sm.new_or_existing('TempObject')
     la1 = sdo.getLastAccessed()
     # time.time() on Windows has coarse granularity (updates at
     # 18.2 Hz -- about once each 0.055 seconds).  We have to sleep
     # long enough so that "the next" call to time.time() actually
     # delivers a larger value.  _last_accessed isn't actually updated
     # unless current time.time() is greater than the last value +
     # WRITEGRANULARITY.  The time() and sleep() are fudged by a
     # factor of 60, though.  The code here used to do
     #     fauxtime.sleep(WRITEGRANULARITY + 1)
     # and that wasn't enough on Windows.  The "+1" only added 1/60th
     # of a second sleep time in real time, much less than the Windows
     # time.time() resolution.  Rounding up 0.055 to 1 digit and
     # multiplying by 60 ensures that we'll actually sleep long enough
     # to get to the next Windows time.time() tick.
     fauxtime.sleep(WRITEGRANULARITY + 0.06 * 60)
     sdo = self.app.sm.get('TempObject')
     self.assert_(sdo.getLastAccessed() > la1)
 def testLastAccessed(self):
     sdo = self.app.sm.new_or_existing('TempObject')
     la1 = sdo.getLastAccessed()
     # time.time() on Windows has coarse granularity (updates at
     # 18.2 Hz -- about once each 0.055 seconds).  We have to sleep
     # long enough so that "the next" call to time.time() actually
     # delivers a larger value.  _last_accessed isn't actually updated
     # unless current time.time() is greater than the last value +
     # WRITEGRANULARITY.  The time() and sleep() are fudged by a
     # factor of 60, though.  The code here used to do
     #     fauxtime.sleep(WRITEGRANULARITY + 1)
     # and that wasn't enough on Windows.  The "+1" only added 1/60th
     # of a second sleep time in real time, much less than the Windows
     # time.time() resolution.  Rounding up 0.055 to 1 digit and
     # multiplying by 60 ensures that we'll actually sleep long enough
     # to get to the next Windows time.time() tick.
     fauxtime.sleep(WRITEGRANULARITY + 0.06 * 60)
     sdo = self.app.sm.get('TempObject')
     self.assert_(sdo.getLastAccessed() > la1)
 def testLastAccessed(self):
     sdo = self.app.sm.new_or_existing('TempObject')
     la1 = sdo.getLastAccessed()
     fauxtime.sleep(WRITEGRANULARITY + 1)
     sdo = self.app.sm.get('TempObject')
     assert sdo.getLastAccessed() > la1, (sdo.getLastAccessed(), la1)