#NEWLINE# def test_normalLookup( self ) : #NEWLINE# #INDENT# '\n        When a cache lookup finds a cached entry from 1 second ago, it is\n        returned with a TTL of original TTL minus the elapsed 1 second.\n        ' #NEWLINE# r = ( [ dns . RRHeader ( 'example.com' , dns . A , dns . IN , 60 , dns . Record_A ( '127.0.0.1' , 60 ) ) ] , [ dns . RRHeader ( 'example.com' , dns . A , dns . IN , 50 , dns . Record_A ( '127.0.0.1' , 50 ) ) ] , [ dns . RRHeader ( 'example.com' , dns . A , dns . IN , 40 , dns . Record_A ( '127.0.0.1' , 40 ) ) ] ) #NEWLINE# clock = task . Clock ( ) #NEWLINE# c = cache . CacheResolver ( reactor = clock ) #NEWLINE# c . cacheResult ( dns . Query ( name = 'example.com' , type = dns . A , cls = dns . IN ) , r ) #NEWLINE# clock . advance ( 1 ) #NEWLINE# def cbLookup( result ) : #NEWLINE# #INDENT# self . assertEquals ( result [ 0 ] [ 0 ] . ttl , 59 ) #NEWLINE# self . assertEquals ( result [ 1 ] [ 0 ] . ttl , 49 ) #NEWLINE# self . assertEquals ( result [ 2 ] [ 0 ] . ttl , 39 ) #NEWLINE# self . assertEquals ( result [ 0 ] [ 0 ] . name . name , 'example.com' ) #NEWLINE# #UNINDENT# return c . lookupAddress ( 'example.com' ) . addCallback ( self )