Add test helpers for creating review request drafts and HTTP requests.

Review Request #10710 — Created Sept. 10, 2019 and submitted

chipx86
Review Board
release-4.0.x
5205558...
reviewboard

Many of the unit tests in our codebase involve creating an HttpRequest
and setting state on it (like users, a LocalSite, or a
ResolverMatch), which is done through a RequestFactory. This
requires a lot of annoying, repeated code.

We also often need to create a ReviewRequestDraft, which is easier,
but still requires more setup than is generally required for our other
models.

This change introduces new helpers for both. create_http_request()
takes care of constructing the HttpRequest from the factory and
setting various properties on it. Down the road, this could be updated
to provide more capabilities like running middleware.

create_review_request_draft() is a simple wrapper around
ReviewRequestDraft.create(), which lets unit tests avoid the extra
import.

A few unit tests have been updated to use create_http_request(), to
ensure that everything works as expected.

Unit tests pass.

Made use of these new helpers in upcoming unit tests.

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

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (aeb5d64)
Loading...