| 86 | return RepositoryCache(repository) |
| 87 | |
| 88 | def test_simple(self, cache: RepositoryCache): |
| 89 | # Single get()s are not cached, since they are used for unique objects like archives. |
| 90 | assert pdchunk(cache.get(H(1))) == b"1234" |
| 91 | assert cache.misses == 1 |
| 92 | assert cache.hits == 0 |
| 93 | |
| 94 | assert [pdchunk(ch) for ch in cache.get_many([H(1)])] == [b"1234"] |
| 95 | assert cache.misses == 2 |
| 96 | assert cache.hits == 0 |
| 97 | |
| 98 | assert [pdchunk(ch) for ch in cache.get_many([H(1)])] == [b"1234"] |
| 99 | assert cache.misses == 2 |
| 100 | assert cache.hits == 1 |
| 101 | |
| 102 | assert pdchunk(cache.get(H(1))) == b"1234" |
| 103 | assert cache.misses == 2 |
| 104 | assert cache.hits == 2 |
| 105 | |
| 106 | def test_meta(self, cache: RepositoryCache): |
| 107 | # Same as test_simple, but not reading the chunk data (metadata only). |