Clean up BaseWebAPITestCase, remove legacy code, and improve performance.
Review Request #13255 — Created Sept. 4, 2023 and submitted
BaseWebAPITestCasewas a very old class with a lot of legacy functions
that were no longer used. With some changes coming up, it was a good
time to remove these and clean up the code.
All the utility functions for creating and deleting certain types of
objects have been removed. Only one was in use, and only in one place,
so the functionality has intstead been moved into the unit test that
We now have typing throughout the class, cleanup of state post-test,
proper documentation, and performance improvements for user login.
The performance improvements remove an unnecessary redundant
query when logging in an administrator on Local Sites. We were querying
for the same user twice. Along with that, we now use a different login
method that lets us pass in an explicit
User, avoiding auth backend
lookups and even more
Userqueries. These save between 10-15 seconds
from the API unit tests locally (there's some variance due to repository
All unit tests pass.