@@ -0,0 +1,1328 @@
+# -*- coding: utf-8 -*-%0A%0Aimport time%0Aimport unittest%0A%0Afrom tracblockdiag import cache%0A%0A%0Aclass TestFunction(unittest.TestCase):%0A    def test_is_obsolete(self):%0A        entry = %7B'time': time.time()%7D%0A        self.assertTrue(cache.is_obsolete(entry, 0))%0A        self.assertFalse(cache.is_obsolete(entry, 3600))%0A%0A    def test_compute_key(self):%0A        def foo_func():%0A            pass%0A        key = cache.compute_key(foo_func, %5B1, 2%5D, %7B'a': 1, 'b': 2%7D)%0A        isinstance(key, str)%0A%0A%0Aclass TestGC(unittest.TestCase):%0A    def setUp(self):%0A        self.gc = cache.GC(2, 60)%0A        cache.cache = %7B%0A            'a': %7B'time': time.time() - 60%7D,%0A            'b': %7B'time': time.time()%7D%0A        %7D%0A%0A    def test_run(self):%0A        # not run yet%0A        expect = cache.cache.copy()%0A        self.gc.run()%0A        self.assertEqual(cache.cache, expect)%0A        # run and collect 'a'%0A        expect.pop('a')%0A        self.gc.run()%0A        self.assertEqual(cache.cache, expect)%0A        # not run yet%0A        cache.cache%5B'b'%5D%5B'time'%5D -= 60%0A        cache.cache%5B'c'%5D = %7B'time': time.time() - 60%7D%0A        expect = cache.cache.copy()%0A        self.gc.run()%0A        self.assertEqual(cache.cache, expect)%0A        # run and collect all entry%0A        self.gc.run()%0A        self.assertEqual(cache.cache, %7B%7D)%0A%0A    def tearDown(self):%0A        cache.cache = %7B%7D%0A

add some tests for cache