<s> import unittest <EOL> import thespian . test . helpers <EOL> from thespian . system . utilis import ExpiryTime <EOL> from datetime import datetime , timedelta <EOL> from time import sleep <EOL> class TestExpiryTime ( unittest . TestCase ) : <EOL> scope = "<STR_LIT>" <EOL> def testNoneExpired ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertFalse ( et . expired ( ) ) <EOL> def testZeroExpired ( self ) : <EOL> et = ExpiryTime ( timedelta ( seconds = <NUM_LIT:0> ) ) <EOL> self . assertTrue ( et . expired ( ) ) <EOL> def testNonZeroExpired ( self ) : <EOL> et = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertFalse ( et . expired ( ) ) <EOL> sleep ( et . remainingSeconds ( ) ) <EOL> self . assertTrue ( et . expired ( ) ) <EOL> def testNoneRemaining ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertIsNone ( et . remaining ( ) ) <EOL> def testZeroRemaining ( self ) : <EOL> et = ExpiryTime ( timedelta ( seconds = <NUM_LIT:0> ) ) <EOL> self . assertEqual ( timedelta ( days = <NUM_LIT:0> ) , et . remaining ( ) ) <EOL> def testNonZeroRemaining ( self ) : <EOL> et = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertTrue ( timedelta ( days = <NUM_LIT:0> ) < et . remaining ( ) ) <EOL> self . assertTrue ( timedelta ( milliseconds = <NUM_LIT:11> ) > et . remaining ( ) ) <EOL> sleep ( et . remainingSeconds ( ) ) <EOL> self . assertEqual ( timedelta ( days = <NUM_LIT:0> ) , et . remaining ( ) ) <EOL> def testNoneRemainingSeconds ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertIsNone ( et . remainingSeconds ( ) ) <EOL> def testZeroRemainingSeconds ( self ) : <EOL> et = ExpiryTime ( timedelta ( microseconds = <NUM_LIT:0> ) ) <EOL> self . assertEqual ( <NUM_LIT:0.0> , et . remainingSeconds ( ) ) <EOL> def testNonZeroRemainingSeconds ( self ) : <EOL> et = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertTrue ( <NUM_LIT:0.0> < et . remainingSeconds ( ) ) <EOL> self . assertTrue ( <NUM_LIT> > et . remainingSeconds ( ) ) <EOL> sleep ( et . remainingSeconds ( ) ) <EOL> self . assertEqual ( <NUM_LIT:0.0> , et . remainingSeconds ( ) ) <EOL> def testNoneRemainingExplicitForever ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertEqual ( <NUM_LIT:5> , et . remaining ( <NUM_LIT:5> ) ) <EOL> def testNoneRemainingSecondsExplicitForever ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertEqual ( <NUM_LIT:9> , et . remainingSeconds ( <NUM_LIT:9> ) ) <EOL> def testNoneStr ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertEqual ( '<STR_LIT>' , str ( et ) ) <EOL> def testZeroStr ( self ) : <EOL> et = ExpiryTime ( timedelta ( hours = <NUM_LIT:0> ) ) <EOL> self . assertTrue ( str ( et ) . startswith ( '<STR_LIT>' ) ) <EOL> def testNonZeroStr ( self ) : <EOL> et = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertTrue ( str ( et ) . startswith ( '<STR_LIT>' ) ) <EOL> sleep ( et . remainingSeconds ( ) ) <EOL> self . assertTrue ( str ( et ) . startswith ( '<STR_LIT>' ) ) <EOL> def testNoneEquality ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertEqual ( et1 , et2 ) <EOL> self . assertEqual ( et2 , et1 ) <EOL> def testNoneToExpiredComparison ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( timedelta ( minutes = <NUM_LIT:0> ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> def testNoneToUnExpiredComparison ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> sleep ( et2 . remainingSeconds ( ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> def testExpiredToExpiredComparison ( self ) : <EOL> et1 = ExpiryTime ( timedelta ( microseconds = <NUM_LIT:0> ) ) <EOL> sleep ( <NUM_LIT> ) <EOL> et2 = ExpiryTime ( timedelta ( minutes = <NUM_LIT:0> ) ) <EOL> self . assertEqual ( et1 , et2 ) <EOL> self . assertEqual ( et2 , et1 ) <EOL> def testExpiredToUnExpiredComparison ( self ) : <EOL> et1 = ExpiryTime ( timedelta ( microseconds = <NUM_LIT:0> ) ) <EOL> et2 = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> sleep ( et2 . remainingSeconds ( ) ) <EOL> self . assertEqual ( et1 , et2 ) <EOL> self . assertEqual ( et2 , et1 ) <EOL> def testUnExpiredToUnExpiredComparison ( self ) : <EOL> et1 = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:15> ) ) <EOL> et2 = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> sleep ( et2 . remainingSeconds ( ) ) <EOL> self . assertNotEqual ( et1 , et2 ) <EOL> self . assertNotEqual ( et2 , et1 ) <EOL> sleep ( et1 . remainingSeconds ( ) ) <EOL> self . assertEqual ( et1 , et2 ) <EOL> self . assertEqual ( et2 , et1 ) <EOL> def testNoneInEquality ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertFalse ( et1 != et2 ) <EOL> self . assertFalse ( et2 != et1 ) <EOL> def testNoneGreaterThanNone ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertFalse ( et1 > et2 ) <EOL> self . assertFalse ( et2 > et1 ) <EOL> def testNoneComparedToZero ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( timedelta ( days = <NUM_LIT:0> ) ) <EOL> self . assertGreater ( et1 , et2 ) <EOL> self . assertLess ( et2 , et1 ) <EOL> self . assertTrue ( et1 >= et2 ) <EOL> self . assertTrue ( et2 <= et1 ) <EOL> def testNoneComparedToNonZero ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertGreater ( et1 , et2 ) <EOL> self . assertLess ( et2 , et1 ) <EOL> self . assertTrue ( et1 > et2 ) <EOL> self . assertTrue ( et2 < et1 ) <EOL> sleep ( et2 . remainingSeconds ( ) ) <EOL> self . assertGreater ( et1 , et2 ) <EOL> self . assertLess ( et2 , et1 ) <EOL> self . assertTrue ( et1 > et2 ) <EOL> self . assertTrue ( et2 < et1 ) <EOL> def testNoneLessThanNone ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertFalse ( et1 < et2 ) <EOL> self . assertFalse ( et2 < et1 ) <EOL> def testNoneLessThanEqualNone ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertTrue ( et1 >= et2 ) <EOL> self . assertTrue ( et2 >= et1 ) <EOL> def testNoneGreaterThanEqualNone ( self ) : <EOL> et1 = ExpiryTime ( None ) <EOL> et2 = ExpiryTime ( None ) <EOL> self . assertTrue ( et1 <= et2 ) <EOL> self . assertTrue ( et2 <= et1 ) <EOL> def testNoneIsFalse ( self ) : <EOL> et = ExpiryTime ( None ) <EOL> self . assertFalse ( et ) <EOL> self . assertFalse ( bool ( et ) ) <EOL> def testZeroIsTrue ( self ) : <EOL> et = ExpiryTime ( timedelta ( minutes = <NUM_LIT:0> ) ) <EOL> self . assertTrue ( et ) <EOL> self . assertTrue ( bool ( et ) ) <EOL> def testNonZeroIsFalse ( self ) : <EOL> et = ExpiryTime ( timedelta ( milliseconds = <NUM_LIT:10> ) ) <EOL> self . assertFalse ( et ) <EOL> self . assertFalse ( bool ( et ) ) <EOL> sleep ( et . remainingSeconds ( ) ) <EOL> self . assertTrue ( et ) <EOL> self . assertTrue ( bool ( et ) ) </s>
