def test_count_by_queryset(self): """Getting the count with an empty cache is a database operation.""" self.create_users(10) cq = CachedQueryset(self.cache, User.objects.all()) with self.assertNumQueries(1): self.assertEqual(10, cq.count()) self.assertIsNone(cq._primary_keys)
def test_count_by_queryset(self): """Getting the count with an empty cache is a database operation.""" self.create_users(10) cq = CachedQueryset(self.cache, User.objects.all()) with self.assertNumQueries(1): self.assertEqual(10, cq.count()) self.assertIsNone(cq._primary_keys)
def test_count_by_pks(self): """Getting the count with a full cache does not query the database.""" self.create_users(10) cq = CachedQueryset(self.cache, User.objects.all(), range(5)) with self.assertNumQueries(0): self.assertEqual(5, cq.count())
def test_count_by_pks(self): """Getting the count with a full cache does not query the database.""" self.create_users(10) cq = CachedQueryset(self.cache, User.objects.all(), range(5)) with self.assertNumQueries(0): self.assertEqual(5, cq.count())