Fish Trophy

chipx86 got a fish trophy!

Fish Trophy

Fix regressions in unit tests due to logging and missing test_scmtools.

Review Request #12421 — Created June 28, 2022 and submitted

Information

Review Board
release-5.0.x

Reviewers

We've had a bit of churn recently with regard to the unit test
infrastructure for SCMTools and in-progress changes. Very temporarily,
unit tests could get away with not using the test_scmtools fixture,
but only as an artifact of state leakage. Recent landed changes
therefore passed at the time without this fixture, but is needed with it
now, since we still need a Tool object in the database and we only do
this if test_scmtools is added.

This change adds this missing fixture to all tests that make use of
repositories/SCMTools.

It also fixes two other test failures.

One was due to a copy/paste of a bad logging.disable() line in a new
test, a copy of the problem fixed in commit 9f51ffeb3. This was causing
test_registry to fail if run after the bad call.

The other was due to a unit test using assertQueries() that wasn't
updated for a change in Review accessibility checks. This has
uncovered a duplicate Q(public=True) that may be a problem,
particularly when trying to use Q(public=False). This needs to be
thoroughly investigated before we ship 5.0, in case there are security
implications.

And finally, it disables warnings in test runs due to the empty content
in test_scmtools by preventing Django from trying to load data from
this fixture in setUpClass().

All unit tests pass.

Summary ID
Fix regressions in unit tests due to logging and missing test_scmtools.
We've had a bit of churn recently with regard to the unit test infrastructure for SCMTools and in-progress changes. Very temporarily, unit tests could get away with not using the `test_scmtools` fixture, but only as an artifact of state leakage. Recent landed changes therefore passed at the time without this fixture, but is needed with it now, since we still need a `Tool` object in the database and we only do this if `test_scmtools` is added. This change adds this missing fixture to all tests that make use of repositories/SCMTools. It also fixes two other test failures. One was due to a copy/paste of a bad `logging.disable()` line in a new test, a copy of the problem fixed in commit 9f51ffeb3. This was causing `test_registry` to fail if run after the bad call. The other was due to a unit test using `assertQueries()` that wasn't updated for a change in `Review` accessibility checks. This has uncovered a duplicate `Q(public=True)` that may be a problem, particularly when trying to use `Q(public=False)`. This needs to be thoroughly investigated before we ship 5.0, in case there are security implications. And finally, it disables warnings in test runs due to the empty content in `test_scmtools` by preventing Django from trying to load data from this fixture in `setUpClass()`.
c77aa391d8ea20bf7a71b3dd698ff404bf40a4eb
Description From Last Updated

I we can probably remove this import, I don't think logging is used anywhere else in the file.

maubinmaubin
maubin
  1. I'll investigate and try to find where that double Q(public=True)) is coming from. Nice to see assertQueries doing it's thing :)

  2. Show all issues

    I we can probably remove this import, I don't think logging is used anywhere else in the file.

  3. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.0.x (77161a9)