diff -r d507cbe169ab -r cbbcfa69a0e7 cubicweb/test/unittest_utils.py --- a/cubicweb/test/unittest_utils.py Tue Apr 24 15:21:18 2018 +0200 +++ b/cubicweb/test/unittest_utils.py Wed Apr 25 15:29:25 2018 +0200 @@ -154,8 +154,28 @@ v = c.get(x, -1) self.assertEqual(v, -1) + def test_iterkeys(self): + """ + Tests the iterating on keys in the cache + """ + c = QueryCache(ceiling=20) + # set 10 values + for x in range(10): + c[x] = x + # arrange for the first 5 to be permanent + for x in range(5): + for r in range(QueryCache._maxlevel + 2): + v = c[x] + self.assertEqual(v, x) + self.assertEqual(c._usage_report(), + {'transientcount': 0, + 'itemcount': 10, + 'permanentcount': 5}) + keys = sorted(c) + for x in range(10): + self.assertEquals(x, keys[x]) - def test_iterator(self): + def test_items(self): """ Tests the iterating on key-value couples in the cache """ @@ -172,7 +192,7 @@ {'transientcount': 0, 'itemcount': 10, 'permanentcount': 5}) - content = sorted(c) + content = sorted(c.items()) for x in range(10): self.assertEquals(x, content[x][0]) self.assertEquals(x, content[x][1])