1
# Copyright 2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
13
from lpx.disk.cache import LRUCache
16
class TestLRUCache(TestCase):
21
self.assertEquals(len(cache), 1)
22
self.assertEquals(list(cache), ["a"])
25
self.assertEquals(len(cache), 0)
26
self.assertEquals(list(cache), [])
31
self.assertEquals(cache["a"], 1)
34
self.assertEquals(cache["a"], 1)
37
self.assertEquals(cache["b"], 2)
38
self.assertEquals(cache["a"], 1)
42
self.assertEquals(list(cache), [])
45
self.assertEquals(list(cache), ["a"])
48
self.assertEquals(list(cache), ["b", "a"])
51
self.assertEquals(list(cache), ["a", "b"])
55
self.assertEquals(len(cache), 0)
58
self.assertEquals(len(cache), 1)
61
self.assertEquals(len(cache), 1)
64
self.assertEquals(len(cache), 2)
66
def test_sizeZero(self):
69
self.assertTrue("a" not in cache)
71
def test_sizeOne(self):
74
self.assertTrue("a" in cache)
77
self.assertTrue("b" in cache)
78
self.assertTrue("a" not in cache)
81
self.assertTrue("a" in cache)
82
self.assertTrue("b" not in cache)
86
return defaultTestLoader.loadTestsFromName(__name__)