Fix the extension configuration tests to not call the view directly.

Review Request #9670 — Created Feb. 18, 2018 and submitted

Information

Djblets
release-1.0.x
4996537...

Reviewers

The extension configuration tests were previously faking a request using
Mock and then calling the configure_extension() view directly. This
worked, but not on Django 1.11. There were a couple of issues, but
the main issue was that CSRF validation was getting in the way on this
version. On Django 1.6, these were largely disabled during test runs,
but that's not the case anymore, and our fake token wasn't fooling
anything. We also couldn't just call the view with a fake GET to get a
token and then pass it during POST, as there are now differences in how
Django's computing and validating these tokens, and it was just too
cumbersome to get around.

To really fix this, we needed to switch to invoking the view via URL and
self.client requests. This is more normal way of calling into the
view, and gives us the advantage of Django's own special handling of
CSRF tokens for test-based requests.

We also had to add the pipeline dependency, which was needed in order
for the response rendering to work correctly so that we'd get the
expected HTTP error codes and CSRF cookie results.

Unit tests pass on Django 1.6 and 1.11 (with other in-progress
compatibility changes).

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.0.x (fe21d46)
Loading...