Make the WebAPI feature tests more robust

Review Request #9130 — Created Aug. 9, 2017 and submitted

Review Board

Some time in the past the WebAPI feature tests started logging errors
due to missing the _local_site_name key on the request. This was due
do the request not going through all the middleware; instead, we were
putting it through a selection of middleware -- just enough for the
tests to pass.

We were doing this because the test resource is not available in the URL
conf we give to Django (as it is temporary and for testing). Now, we
generate a URL conf for each test as we are running it and pass that to
Django instead. That way, all the requests can go through the test
client, which will put them through middleware we use.

In addition I've rewritten the language in the specified test to outline
what exactly the feature and resource are doing: they are for testing
and hence should be called TestingFeature, TestingResource, etc.

Ran unit tests.

  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.


  2. reviewboard/webapi/tests/ (Diff revision 2)

    Global variables should be before all classes.

  3. reviewboard/webapi/tests/ (Diff revision 2)

    How about doing this in a setUpClass and tearing down the patterns in a tearDownClass? Much of this really doesn't need to be done per-test. We can also use @override_settings on the class to set the ROOT_URLCONF globally for the class, instead of in the tests.

  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (3063acf)