Beispiel #1
0
 def testUnExpiredToUnExpiredComparison(self):
     et1 = ExpiryTime(timedelta(milliseconds=15))
     et2 = ExpiryTime(timedelta(milliseconds=10))
     assert et1 != et2
     assert et2 != et1
     sleep(et2.remainingSeconds())
     print(str(et1), str(et2))
     assert et1 != et2
     assert et2 != et1
     sleep(et1.remainingSeconds())
     assert et1 == et2
     assert et2 == et1
 def testUnExpiredToUnExpiredComparison(self):
     et1 = ExpiryTime(timedelta(milliseconds=15))
     et2 = ExpiryTime(timedelta(milliseconds=10))
     assert et1 != et2
     assert et2 != et1
     sleep(et2.remainingSeconds())
     print(str(et1), str(et2))
     assert et1 != et2
     assert et2 != et1
     sleep(et1.remainingSeconds())
     assert et1 == et2
     assert et2 == et1
 def testNonZeroIsFalse(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert not et
     assert not bool(et)
     sleep(et.remainingSeconds())
     assert et
     assert bool(et)
Beispiel #4
0
 def testNonZeroIsFalse(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert not et
     assert not bool(et)
     sleep(et.remainingSeconds())
     assert et
     assert bool(et)
 def testNoneToUnExpiredComparison(self):
     et1 = ExpiryTime(None)
     et2 = ExpiryTime(timedelta(milliseconds=10))
     assert et1 != et2
     assert et2 != et1
     sleep(et2.remainingSeconds())
     assert et1 != et2
     assert et2 != et1
Beispiel #6
0
 def testNoneToUnExpiredComparison(self):
     et1 = ExpiryTime(None)
     et2 = ExpiryTime(timedelta(milliseconds=10))
     assert et1 != et2
     assert et2 != et1
     sleep(et2.remainingSeconds())
     assert et1 != et2
     assert et2 != et1
 def testNoneComparedToNonZero(self):
     et1 = ExpiryTime(None)
     et2 = ExpiryTime(timedelta(milliseconds=10))
     # None == forever, so it is greater than anything, although equal to itself
     assert et1 > et2
     assert et2 < et1
     assert et1 > et2
     assert et2 < et1
     sleep(et2.remainingSeconds())
     assert et1 > et2
     assert et2 < et1
     assert et1 > et2
     assert et2 < et1
Beispiel #8
0
 def testNoneComparedToNonZero(self):
     et1 = ExpiryTime(None)
     et2 = ExpiryTime(timedelta(milliseconds=10))
     # None == forever, so it is greater than anything, although equal to itself
     assert et1 > et2
     assert et2 < et1
     assert et1 > et2
     assert et2 < et1
     sleep(et2.remainingSeconds())
     assert et1 > et2
     assert et2 < et1
     assert et1 > et2
     assert et2 < et1
Beispiel #9
0
 def testNoneRemainingSecondsExplicitForever(self):
     et = ExpiryTime(None)
     assert 9 == et.remainingSeconds(9)
Beispiel #10
0
 def testNonZeroRemainingSeconds(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert 0.0 < et.remainingSeconds()
     assert 0.0101 > et.remainingSeconds()
     sleep(et.remainingSeconds())
     assert 0.0 == et.remainingSeconds()
Beispiel #11
0
 def testZeroRemainingSeconds(self):
     et = ExpiryTime(timedelta(microseconds=0))
     assert 0.0 == et.remainingSeconds()
Beispiel #12
0
 def testNoneRemainingSeconds(self):
     et = ExpiryTime(None)
     assert et.remainingSeconds() is None
Beispiel #13
0
 def testNonZeroRemaining(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert timedelta(days=0) < et.remaining()
     assert timedelta(milliseconds=11) > et.remaining()
     sleep(et.remainingSeconds())
     assert timedelta(days=0) == et.remaining()
Beispiel #14
0
 def testNonZeroRemaining(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert timedelta(days=0) < et.remaining()
     assert timedelta(milliseconds=11) > et.remaining()
     sleep(et.remainingSeconds())
     assert timedelta(days=0) == et.remaining()
Beispiel #15
0
 def testNoneRemainingSeconds(self):
     et = ExpiryTime(None)
     assert et.remainingSeconds() is None
Beispiel #16
0
 def testNonZeroStr(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert str(et).startswith('Expires_in_0:00:00.0')
     sleep(et.remainingSeconds())
     assert str(et).startswith('Expired_for_0:00:00')
Beispiel #17
0
 def testZeroRemainingSeconds(self):
     et = ExpiryTime(timedelta(microseconds=0))
     assert 0.0 == et.remainingSeconds()
Beispiel #18
0
 def testNonZeroStr(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert str(et).startswith('Expires_in_0:00:00.0')
     sleep(et.remainingSeconds())
     assert str(et).startswith('Expired_for_0:00:00')
Beispiel #19
0
 def testNoneRemainingSecondsExplicitForever(self):
     et = ExpiryTime(None)
     assert 9 == et.remainingSeconds(9)
Beispiel #20
0
 def testNonZeroRemainingSeconds(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert 0.0 < et.remainingSeconds()
     assert 0.0101 > et.remainingSeconds()
     sleep(et.remainingSeconds())
     assert 0.0 == et.remainingSeconds()
Beispiel #21
0
 def testNonZeroExpired(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert not et.expired()
     sleep(et.remainingSeconds())
     assert et.expired()
Beispiel #22
0
 def testNonZeroExpired(self):
     et = ExpiryTime(timedelta(milliseconds=10))
     assert not et.expired()
     sleep(et.remainingSeconds())
     assert et.expired()