Replace uses of client.get and client.post

We have a `client_request` fixture which does a bunch of useful stuff
like:
- checking the status code of the response
- returning a `BeautifulSoup` object

Lots of our tests still use an older fixture called `client`. This is
not as good because it:
- returns a raw `Response` object
- doesn’t do the additional checks
- means our tests contain a lot of repetetive boilerplate like `page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')`

This commit converts all the tests which had a `client.get(…)` or
`client.post(…)` statement to use their equivalents on `client_request`
instead.

Subsequent commits will remove uses of `client` in other tests, but
doing it this way means the work can be broken up into more manageable
chunks.
This commit is contained in:
Chris Hill-Scott
2022-01-04 15:40:42 +00:00
parent 07318b2d11
commit 7e707db4b2
24 changed files with 951 additions and 726 deletions

View File

@@ -1,10 +1,15 @@
def test_crown_logo(client):
def test_crown_logo(client_request):
# This image is used by the email templates, so we should be really careful to make
# sure that its always there.
response = client.get('/static/images/email-template/crown-32px.gif')
assert response.status_code == 200
client_request.logout()
client_request.get_response_from_url(
'/static/images/email-template/crown-32px.gif',
_expected_status=200,
)
def test_static_404s_return(client):
response = client.get('/static/images/some-image-that-doesnt-exist.png')
assert response.status_code == 404
def test_static_404s_return(client_request):
client_request.get_response_from_url(
'/static/images/some-image-that-doesnt-exist.png',
_expected_status=404,
)