Make the WebAPI feature tests more robust

Review Request #9130 - Created Aug. 9, 2017 and updated

Barret Rennie
Review Board
release-3.0.x
reviewboard

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.

  • 2
  • 1
  • 0
  • 3
Description From Last Updated
Global variables should be before all classes. Christian Hammond Christian Hammond
How about doing this in a setUpClass and tearing down the patterns in a tearDownClass? Much of this really doesn't ... Christian Hammond Christian Hammond
Barret Rennie
Review request changed

Checks run (2 succeeded)

JSHint passed.
flake8 passed.
Christian Hammond
  1. 
      
  2. reviewboard/webapi/tests/test_base.py (Diff revision 2)
     
     
     

    Global variables should be before all classes.

  3. reviewboard/webapi/tests/test_base.py (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.

  4. 
      
Loading...