Add expected queries and enhance tests for Group access queries.

Review Request #13406 — Created Nov. 7, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

This introduces the reviewboard.reviews.testing.queries.review_groups
module for query-building functions for tests. It contains the following
methods:

  • get_review_groups_accessible_q()
  • get_review_groups_accessible_prep_equeries()
  • get_review_groups_accessible_equeries()
  • get_review_groups_accessible_ids_equeries()

These generate expected Q objects and queries that matches calls to
Group.objects.accessible() and Group.objects.accessible_ids().
They're written in a verbose manner that ensures we only ever test
against finalized Q expressions, to minimize chances of regressions or
unexpected behavior.

The unit tests for .accessible() and .accessible_ids() have been
completely rewritten. They now check against these expected queries, but
they've also been expanded considerably to more thoroughly check access
with positive and negative test data, to better catch regressions. The
approach being used here will be carried over to other accessibility
tests for the next batch of this peformance work.

Unit tests pass.

Diff Revision 3

This is not the most recent revision of the diff. The latest diff is revision 6. See what's changed.

orig
1
2
3
4
5
6

Commits

First Last Summary ID Author
Add expected queries and enhance tests for Group access queries.
This introduces a new `reviewboard.reviews.testing.queries` module that contains the following utility functions for building expected queries for unit tests: * `get_review_groups_accessible_equeries()` * `get_review_groups_accessible_ids_equeries()` These generate expected queries that matches calls to `Group.objects.accessible()` and `Group.objects.accessible_ids()`. They're written in a verbose manner that ensures we only ever test against finalized Q expressions, to minimize chances of regressions or unexpected behavior. The unit tests for `.accessible()` and `.accessible_ids()` have been completely rewritten. They now check against these expected queries, but they've also been expanded considerably to more thoroughly check access with positive and negative test data, to better catch regressions. The approach being used here will be carried over to other accessibility tests for the next batch of this peformance work.
f91c7709d9b681c8e8b99ee7a03481fa06de6e88 Christian Hammond
reviewboard/reviews/managers.py
reviewboard/reviews/testing/__init__.py
reviewboard/reviews/testing/queries.py
reviewboard/reviews/tests/test_review_group_manager.py
Loading...