Exemplo n.º 1
0
 def test_cache_fuzz(self):
     from pyff.constants import config
     import time
     config.randomize_cache_ttl = False
     config.cache_ttl = 0
     now = int(time.time())
     assert(is_past_ttl(now - 1, ttl=config.cache_ttl))
     assert(not is_past_ttl(now, ttl=config.cache_ttl))
     config.cache_ttl = 3
     config.randomize_cache_ttl = True
     assert(is_past_ttl(now - 6, ttl=config.cache_ttl))
     assert(not is_past_ttl(now, ttl=config.cache_ttl))
     assert(is_past_ttl(now - 100, ttl=config.cache_ttl))
Exemplo n.º 2
0
 def is_valid(self, url):
     nfo = self.icons.get(url, None)
     if nfo is None or 'last_seen' not in nfo or is_past_ttl(
             int(nfo['last_seen']), ttl=config.cache_ttl_icons):
         return False
     return True