Add TestCase.assertQueries(), for advanced query checks.

Review Request #12345 — Created June 8, 2022 and submitted — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

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.

Made use of this in a bunch of unit tests in Review Board. Tested all
the major types of operations that can be performed when querying.

Changes between revision 5 and 6

orig
1
2
3
4
5
6

Commits

Summary ID Author
Add TestCase.assertQueries(), for advanced query checks.
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.
30dba59525421a643aaee15af796d6476e4462b5 Christian Hammond
Add TestCase.assertQueries(), for advanced query checks.
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.
5d12cc2d9e4d1b9fc1d61c79b4e494d4756dea7e Christian Hammond
djblets/testing/testcases.py
Loading...