MCPcopy
hub / github.com/django/django / test_in_bulk_lots_of_ids

Method test_in_bulk_lots_of_ids

tests/lookup/tests.py:210–221  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

208 Article.objects.in_bulk(headline__startswith="Blah")
209
210 def test_in_bulk_lots_of_ids(self):
211 test_range = 2000
212 max_query_params = connection.features.max_query_params
213 expected_num_queries = (
214 ceil(test_range / max_query_params) if max_query_params else 1
215 )
216 Author.objects.bulk_create(
217 [Author() for i in range(test_range - Author.objects.count())]
218 )
219 authors = {author.pk: author for author in Author.objects.all()}
220 with self.assertNumQueries(expected_num_queries):
221 self.assertEqual(Author.objects.in_bulk(authors), authors)
222
223 def test_in_bulk_with_field(self):
224 self.assertEqual(

Callers

nothing calls this directly

Calls 6

bulk_createMethod · 0.80
assertNumQueriesMethod · 0.80
in_bulkMethod · 0.80
AuthorClass · 0.70
countMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected