Reduce the errors related to user fixtures

We were using user fixtures in a lot of parameterized tests, but this is
no longer allowed in Pytest 5. To avoid having to split up the parametrized
tests (which would make the test files a lot longer and slightly more
difficult to read) this commit creates functions which return various types
of user json so that we can use these as the test parameters instead.
This commit is contained in:
Katie Smith
2019-12-19 16:59:07 +00:00
parent b62018a8e4
commit e4134072d9
17 changed files with 412 additions and 231 deletions

View File

@@ -8,12 +8,7 @@ from app.navigation import (
MainNavigation,
OrgNavigation,
)
from tests.conftest import (
ORGANISATION_ID,
SERVICE_ONE_ID,
active_caseworking_user,
normalize_spaces,
)
from tests.conftest import ORGANISATION_ID, SERVICE_ONE_ID, normalize_spaces
def flask_app():
@@ -181,14 +176,14 @@ def test_navigation_urls(
def test_caseworkers_get_caseworking_navigation(
client_request,
mocker,
fake_uuid,
mock_get_template_folders,
mock_get_service_templates,
mock_has_no_jobs,
active_caseworking_user,
):
mocker.patch(
'app.user_api_client.get_user',
return_value=active_caseworking_user(fake_uuid)
return_value=active_caseworking_user
)
page = client_request.get('main.choose_template', service_id=SERVICE_ONE_ID)
assert normalize_spaces(page.select_one('header + .govuk-width-container nav').text) == (
@@ -199,14 +194,14 @@ def test_caseworkers_get_caseworking_navigation(
def test_caseworkers_see_jobs_nav_if_jobs_exist(
client_request,
mocker,
fake_uuid,
mock_get_service_templates,
mock_get_template_folders,
mock_has_jobs,
active_caseworking_user,
):
mocker.patch(
'app.user_api_client.get_user',
return_value=active_caseworking_user(fake_uuid)
return_value=active_caseworking_user
)
page = client_request.get('main.choose_template', service_id=SERVICE_ONE_ID)
assert normalize_spaces(page.select_one('header + .govuk-width-container nav').text) == (