Stop using logged_in_client fixture

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 `logged_in_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 using `logged_in_client` to:
use `client_request` instead.
This commit is contained in:
Chris Hill-Scott
2021-12-31 12:08:14 +00:00
parent 50eae6f935
commit 0706664be4
20 changed files with 341 additions and 291 deletions

View File

@@ -89,7 +89,6 @@ from tests.conftest import (
@freeze_time('2020-01-01 01:00')
def test_can_show_notifications(
client_request,
logged_in_client,
service_one,
mock_get_notifications,
mock_get_service_statistics,
@@ -183,12 +182,12 @@ def test_can_show_notifications(
to=expected_to_argument,
)
json_response = logged_in_client.get(url_for(
json_response = client_request.get_response(
'main.get_notifications_as_json',
service_id=service_one['id'],
status=status_argument,
**extra_args
))
)
json_content = json.loads(json_response.get_data(as_text=True))
assert json_content.keys() == {'counts', 'notifications', 'service_data_retention_days'}