mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Replace uses of client to set request context
Some tests use the `client` fixture but don’t call any of its methods. The reason for doing this is because the test depends on something in the request context. This commit replaces all those instances with `client_request`, which also sets the request context. These tests are the last ones that still use the `client` fixture. By replacing it with `client_request` we will be able to say that no tests should be using the `client` fixture directly.
This commit is contained in:
@@ -577,7 +577,7 @@ STATISTICS = {
|
||||
}
|
||||
|
||||
|
||||
def test_get_status_filters_calculates_stats(client):
|
||||
def test_get_status_filters_calculates_stats(client_request):
|
||||
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
|
||||
|
||||
assert {label: count for label, _option, _link, count in ret} == {
|
||||
@@ -588,7 +588,7 @@ def test_get_status_filters_calculates_stats(client):
|
||||
}
|
||||
|
||||
|
||||
def test_get_status_filters_in_right_order(client):
|
||||
def test_get_status_filters_in_right_order(client_request):
|
||||
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
|
||||
|
||||
assert [label for label, _option, _link, _count in ret] == [
|
||||
@@ -596,7 +596,7 @@ def test_get_status_filters_in_right_order(client):
|
||||
]
|
||||
|
||||
|
||||
def test_get_status_filters_constructs_links(client):
|
||||
def test_get_status_filters_constructs_links(client_request):
|
||||
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
|
||||
|
||||
link = ret[0][2]
|
||||
|
||||
@@ -370,7 +370,7 @@ def test_inbox_not_accessible_to_service_without_permissions(
|
||||
|
||||
|
||||
def test_anyone_can_see_inbox(
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mocker,
|
||||
@@ -382,7 +382,7 @@ def test_anyone_can_see_inbox(
|
||||
|
||||
validate_route_permission_with_client(
|
||||
mocker,
|
||||
client,
|
||||
client_request,
|
||||
'GET',
|
||||
200,
|
||||
url_for('main.inbox', service_id=service_one['id']),
|
||||
@@ -747,7 +747,7 @@ def test_should_show_monthly_breakdown_of_template_usage(
|
||||
|
||||
|
||||
def test_anyone_can_see_monthly_breakdown(
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mocker,
|
||||
@@ -755,7 +755,7 @@ def test_anyone_can_see_monthly_breakdown(
|
||||
):
|
||||
validate_route_permission_with_client(
|
||||
mocker,
|
||||
client,
|
||||
client_request,
|
||||
'GET',
|
||||
200,
|
||||
url_for('main.monthly', service_id=service_one['id']),
|
||||
@@ -1605,7 +1605,6 @@ def test_org_breadcrumbs_do_not_show_if_service_has_no_org(
|
||||
|
||||
def test_org_breadcrumbs_do_not_show_if_user_is_not_an_org_member(
|
||||
mocker,
|
||||
client,
|
||||
mock_get_service_templates_when_no_templates_exist,
|
||||
mock_has_no_jobs,
|
||||
active_caseworking_user,
|
||||
|
||||
@@ -2908,7 +2908,7 @@ def test_dont_show_preview_letter_templates_for_bad_filetype(
|
||||
def test_route_permissions(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mock_get_service_template,
|
||||
@@ -2943,7 +2943,7 @@ def test_route_permissions(
|
||||
def test_route_permissions_send_check_notifications(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mock_send_notification,
|
||||
@@ -2953,12 +2953,12 @@ def test_route_permissions_send_check_notifications(
|
||||
response_code,
|
||||
method
|
||||
):
|
||||
with client.session_transaction() as session:
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = '07700900001'
|
||||
session['placeholders'] = {'name': 'a'}
|
||||
validate_route_permission_with_client(
|
||||
mocker,
|
||||
client,
|
||||
client_request,
|
||||
method,
|
||||
response_code,
|
||||
url_for(
|
||||
@@ -2980,7 +2980,7 @@ def test_route_permissions_send_check_notifications(
|
||||
def test_route_permissions_sending(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mock_get_service_template,
|
||||
|
||||
@@ -2015,7 +2015,7 @@ def test_ready_to_go_live(
|
||||
def test_route_permissions(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
single_reply_to_email_address,
|
||||
@@ -2050,7 +2050,7 @@ def test_route_permissions(
|
||||
def test_route_invalid_permissions(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
route,
|
||||
@@ -2077,7 +2077,7 @@ def test_route_invalid_permissions(
|
||||
def test_route_for_platform_admin(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
single_reply_to_email_address,
|
||||
|
||||
@@ -2232,7 +2232,7 @@ def test_route_permissions(
|
||||
route,
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mock_get_service_template,
|
||||
@@ -2259,7 +2259,7 @@ def test_route_permissions(
|
||||
def test_route_permissions_for_choose_template(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_get_template_folders,
|
||||
service_one,
|
||||
@@ -2290,7 +2290,7 @@ def test_route_invalid_permissions(
|
||||
route,
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
service_one,
|
||||
mock_get_service_template,
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_should_404_if_no_mobile_number_for_tour_start(
|
||||
def test_should_403_if_user_does_not_have_send_permissions_for_tour_start(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_get_service_template_with_multiple_placeholders,
|
||||
service_one,
|
||||
@@ -258,7 +258,7 @@ def test_should_404_for_get_tour_step_0(
|
||||
def test_should_403_if_user_does_not_have_send_permissions_for_tour_step(
|
||||
mocker,
|
||||
notify_admin,
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_get_service_template_with_multiple_placeholders,
|
||||
service_one,
|
||||
|
||||
@@ -9,9 +9,9 @@ from app.models.webauthn_credential import RegistrationError, WebAuthnCredential
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def webauthn_authentication_post_data(fake_uuid, webauthn_credential, client):
|
||||
def webauthn_authentication_post_data(fake_uuid, webauthn_credential, client_request):
|
||||
|
||||
_set_up_webauthn_session(fake_uuid, client)
|
||||
_set_up_webauthn_session(fake_uuid, client_request)
|
||||
|
||||
credential_id = WebAuthnCredential(webauthn_credential).to_credential_data().credential_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user