Fix a regression with running selective unit tests.

Review Request #11345 — Created Dec. 23, 2020 and submitted

Information

Review Board
release-4.0.x

Reviewers

The recent change to fix the SiteConfiguration changes on version-only
upgrades broke running selective unit tests. This happened because the
test runner, which normally emits post-migrate signals on database
setup, no longer had a way to set up the configuration, or the tools
entries for that matter.

We now initialize the site configuration after Django sets up the
database in the test runner, so that we can have the correct state.

Note that we cannot call finalize_setup(), as we'll still end up with
some state (logging state, at the very least) that's set up wrong, due
due to the Tool import process. This is worth digging into later, but
it wasn't trivial to work around without possibly regressing something
else in this change.

It does, however, set some default state we use for all unit tests
before any transactions begin, to avoid a database write in each test's
setUp().

The entire test suite, and various partial test runs, all run succesfully.

Summary ID
Fix a regression with running selective unit tests.
The recent change to fix the `SiteConfiguration` changes on version-only upgrades broke running selective unit tests. This happened because the test runner, which normally emits post-migrate signals on database setup, no longer had a way to set up the configuration, or the tools entries for that matter. We now initialize the site configuration after Django sets up the database in the test runner, so that we can have the correct state. Note that we cannot call `finalize_setup()`, as we'll still end up with some state (logging state, at the very least) that's set up wrong, due due to the `Tool` import process. This is worth digging into later, but it wasn't trivial to work around without possibly regressing something else in this change. It does, however, set some default state we use for all unit tests before any transactions begin, to avoid a database write in each test's `setUp()`.
2de9792cfbdde396ca08f79ec3b2d5a859677af8
Description From Last Updated

F401 'reviewboard.admin.management.sites.init_siteconfig' imported but unused

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

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (fe88615)