• 
      

    Make the WebAPI feature tests more robust

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

    Information

    Review Board
    release-3.0.x

    Reviewers

    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.

    Description From Last Updated

    E122 continuation line missing indentation or outdented

    reviewbotreviewbot

    Global variables should be before all classes.

    chipx86chipx86

    How about doing this in a setUpClass and tearing down the patterns in a tearDownClass? Much of this really doesn't …

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

    flake8

    brennie
    chipx86
    1. 
        
    2. reviewboard/webapi/tests/test_base.py (Diff revision 2)
       
       
       
      Show all issues

      Global variables should be before all classes.

    3. reviewboard/webapi/tests/test_base.py (Diff revision 2)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      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. 
        
    brennie
    david
    1. Ship It!
    2. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (3063acf)