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
2022-01-10 14:39:44 +00:00
parent 50eae6f935
commit 0706664be4
20 changed files with 341 additions and 291 deletions
+14 -6
View File
@@ -683,7 +683,7 @@ def test_dont_cancel_letter_job_when_to_early_to_cancel(
@freeze_time("2016-01-01 00:00:00.000001")
def test_should_show_updates_for_one_job_as_json(
logged_in_client,
client_request,
service_one,
active_user_with_permissions,
mock_get_notifications,
@@ -693,9 +693,13 @@ def test_should_show_updates_for_one_job_as_json(
mocker,
fake_uuid,
):
response = logged_in_client.get(url_for('main.view_job_updates', service_id=service_one['id'], job_id=fake_uuid))
response = client_request.get(
'main.view_job_updates',
service_id=service_one['id'],
job_id=fake_uuid,
_raw_response=True,
)
assert response.status_code == 200
content = json.loads(response.get_data(as_text=True))
assert 'sending' in content['counts']
assert 'delivered' in content['counts']
@@ -710,7 +714,7 @@ def test_should_show_updates_for_one_job_as_json(
@freeze_time("2016-01-01 00:00:00.000001")
def test_should_show_updates_for_scheduled_job_as_json(
logged_in_client,
client_request,
service_one,
active_user_with_permissions,
mock_get_notifications,
@@ -727,9 +731,13 @@ def test_should_show_updates_for_scheduled_job_as_json(
processing_started='2016-06-01T15:00:00+00:00',
)})
response = logged_in_client.get(url_for('main.view_job_updates', service_id=service_one['id'], job_id=fake_uuid))
response = client_request.get(
'main.view_job_updates',
service_id=service_one['id'],
job_id=fake_uuid,
_raw_response=True,
)
assert response.status_code == 200
content = response.json
assert 'sending' in content['counts']
assert 'delivered' in content['counts']