예제 #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)
예제 #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)
예제 #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)
예제 #4
0
 def test_iter_empty_list(self):
     """Iterating an PkOnlyQueryset returns an empty list."""
     pkvl = PkOnlyQueryset(self.cache, User, [])
     self.assertFalse(list(pkvl))
예제 #5
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)
예제 #6
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)