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

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

chipx86
Djblets
release-3.x
djblets

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.

Summary
Add TestCase.assertQueries(), for advanced query checks.
Description From Last Updated

too many blank lines (2) Column: 9 Error code: E303

reviewbotreviewbot

expected 1 blank line before a nested definition, found 0 Column: 9 Error code: E306

reviewbotreviewbot

redefinition of unused '_execute_sql' from line 429 Column: 9 Error code: F811

reviewbotreviewbot

redefinition of unused '_execute_sql' from line 441 Column: 9 Error code: F811

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
chipx86
chipx86
chipx86
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.x (685c48c)
Loading...