Replace uses of client to set request context

Some tests use the `client` fixture but don’t call any of its methods.
The reason for doing this is because the test depends on something in
the request context.

This commit replaces all those instances with `client_request`, which
also sets the request context.

These tests are the last ones that still use the `client` fixture. By
replacing it with `client_request` we will be able to say that no tests
should be using the `client` fixture directly.
This commit is contained in:
Chris Hill-Scott
2022-01-04 18:33:23 +00:00
parent 7e707db4b2
commit 6540701aa7
19 changed files with 87 additions and 70 deletions

View File

@@ -2926,12 +2926,26 @@ def client_request(_logged_in_client, mocker, service_one): # noqa (C901 too co
_optional_args="",
_content_type=None,
**endpoint_kwargs
):
return ClientRequest.post_response_from_url(
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
_data=_data,
_content_type=_content_type,
_expected_status=_expected_status,
)
@staticmethod
def post_response_from_url(
url,
_data=None,
_expected_status=302,
_content_type=None,
):
post_kwargs = {}
if _content_type:
post_kwargs.update(content_type=_content_type)
resp = _logged_in_client.post(
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
url,
data=_data,
**post_kwargs
)