Beispiel #1
0
 def test_iter(self):
     """Iterating a PkOnlyQueryset returns PkOnlyModels."""
     pks = [1, 2, 3]
     pkvl = PkOnlyQueryset(self.cache, User, pks)
     for pk, pm in zip(pks, pkvl):
         self.assertIsInstance(pm, PkOnlyModel)
         self.assertEqual(pm.pk, pk)
Beispiel #2
0
 def test_values_list(self):
     """A limited version of values_list returns pks."""
     pkvl = PkOnlyQueryset(self.cache, User, range(5))
     values_list = pkvl.values_list('id', flat=True)
     self.assertEqual(range(5), values_list)
Beispiel #3
0
 def test_filter_all(self):
     """Filtering with .all() returns the PkOnlyQueryset."""
     pkvl = PkOnlyQueryset(self.cache, User, range(5))
     pkall = pkvl.all()
     self.assertEqual(pkvl, pkall)
Beispiel #4
0
 def test_iter_empty_list(self):
     """Iterating an PkOnlyQueryset returns an empty list."""
     pkvl = PkOnlyQueryset(self.cache, User, [])
     self.assertFalse(list(pkvl))
 def test_values_list(self):
     """A limited version of values_list returns pks."""
     pkvl = PkOnlyQueryset(self.cache, User, range(5))
     values_list = pkvl.values_list('id', flat=True)
     self.assertEqual(range(5), values_list)
 def test_filter_all(self):
     """Filtering with .all() returns the PkOnlyQueryset."""
     pkvl = PkOnlyQueryset(self.cache, User, range(5))
     pkall = pkvl.all()
     self.assertEqual(pkvl, pkall)