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

@@ -669,7 +669,7 @@ def test_shows_link_to_end_tour(
def test_go_to_dashboard_after_tour_link(
logged_in_client,
client_request,
mocker,
api_user_active,
mock_login,
@@ -678,11 +678,15 @@ def test_go_to_dashboard_after_tour_link(
mock_delete_service_template,
fake_uuid
):
resp = logged_in_client.get(
url_for('main.go_to_dashboard_after_tour', service_id=fake_uuid, example_template_id=fake_uuid)
client_request.get(
'main.go_to_dashboard_after_tour',
service_id=fake_uuid,
example_template_id=fake_uuid,
_expected_redirect=url_for(
"main.service_dashboard",
service_id=fake_uuid,
_external=True,
)
)
assert resp.status_code == 302
assert resp.location == url_for("main.service_dashboard", service_id=fake_uuid, _external=True)
mock_delete_service_template.assert_called_once_with(fake_uuid, fake_uuid)