Make the WebAPI feature tests more robust
Review Request #9130 - Created Aug. 9, 2017 and updated
Some time in the past the WebAPI feature tests started logging errors
due to missing the
_local_site_namekey 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
Ran unit tests.
Global variables should be before all classes.
How about doing this in a
setUpClassand tearing down the patterns in a
tearDownClass? Much of this really doesn't need to be done per-test. We can also use
@override_settingson the class to set the
ROOT_URLCONFglobally for the class, instead of in the tests.