예제 #1
0
 def test_not_expired(self):
     cache = Cache(self.__dir, 40, min_time=1)
     val = b"0123456789"
     cache.set("key1", val)
     with self.assertRaises(ProtectedError):
         cache.delete("key1")
     time.sleep(1)
     cache.delete("key1")
     self.assertEqual(cache.size, 0)
예제 #2
0
    def test_delete(self):
        cache = Cache(self.__dir, 25, min_time=0)
        val = b"0123456789"
        cache.set("key1", val)
        self.assertTrue(cache.has("key1"))
        self.assertEqual(cache.size, 10)

        cache.delete("key1")

        self.assertFalse(cache.has("key1"))
        self.assertEqual(cache.size, 0)
예제 #3
0
 def test_delete_missing(self):
     cache = Cache(self.__dir, 0, min_time=0)
     cache.delete("missing1")
     cache.delete("missing2")