Add test helpers for creating review request drafts and HTTP requests.
Review Request #10710 — Created Sept. 10, 2019 and submitted
Many of the unit tests in our codebase involve creating an
HttpRequest
and setting state on it (like users, aLocalSite
, or a
ResolverMatch
), which is done through aRequestFactory
. 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 theHttpRequest
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.