Exemple #1
0
    def test_does_not_expire_by_default(self, _update_cache_data):
        mydict = CachedDict(timeout=100)
        mydict._cache = {}
        mydict._last_updated = time.time()
        mydict._populate()

        self.assertFalse(_update_cache_data.called)
Exemple #2
0
    def test_reset_does_expire(self, _update_cache_data):
        mydict = CachedDict(timeout=100)
        mydict._cache = {}
        mydict._last_updated = time.time()
        mydict._populate(reset=True)

        _update_cache_data.assert_called_once_with()
Exemple #3
0
    def test_expired_does_update_data(self, _update_cache_data):
        mydict = CachedDict()
        mydict._cache = {}
        mydict._last_updated = time.time()
        mydict._populate()

        _update_cache_data.assert_called_once_with()
Exemple #4
0
 def test_is_expired_within_bounds(self):
     mydict = CachedDict(timeout=100)
     mydict._last_updated = time.time()
     self.assertFalse(mydict.is_expired())
Exemple #5
0
 def test_is_expired_last_updated_beyond_timeout(self):
     mydict = CachedDict(timeout=100)
     mydict._last_updated = time.time() - 101
     self.assertTrue(mydict.is_expired())
Exemple #6
0
 def test_is_expired_missing_last_updated(self):
     mydict = CachedDict(timeout=100)
     mydict._last_updated = None
     self.assertTrue(mydict.is_expired())