This introduces TestCase.assertQueries()
, a new unit test function
that can assert not just the number of queries performed by also the
complexity of those queries.
This takes in a list of queries built by Django and executed, checking
them for the lists of fields selected, tables joined, filter
conditions, annotations, ordering, and more.
This can offer a lot of advantages when writing tests, helping ensure
that queries are as performant as possible, or at least don't contain
unexpected complexity.