MCPcopy
hub / github.com/django/django / test_annotations

Method test_annotations

tests/raw_query/tests.py:331–345  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

329 self.assertTrue(cm.exception.__suppress_context__)
330
331 def test_annotations(self):
332 query = (
333 "SELECT a.*, count(b.id) as book_count "
334 "FROM raw_query_author a "
335 "LEFT JOIN raw_query_book b ON a.id = b.author_id "
336 "GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id"
337 )
338 expected_annotations = (
339 ("book_count", 3),
340 ("book_count", 0),
341 ("book_count", 1),
342 ("book_count", 0),
343 )
344 authors = Author.objects.order_by("pk")
345 self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
346
347 def test_white_space_query(self):
348 query = " SELECT * FROM raw_query_author"

Callers

nothing calls this directly

Calls 2

order_byMethod · 0.80

Tested by

no test coverage detected