diff --git a/tests/app/main/forms/test_create_key_form.py b/tests/app/main/forms/test_create_key_form.py index 0768c271a..3539d29b4 100644 --- a/tests/app/main/forms/test_create_key_form.py +++ b/tests/app/main/forms/test_create_key_form.py @@ -5,11 +5,11 @@ from app.main.forms import CreateKeyForm @pytest.mark.parametrize( - "expiry_date, expected_errors", - ( + ("expiry_date", "expected_errors"), + [ (None, ["A key with this name already exists"]), ("2001-01-01 01:01:01", None), - ), + ], ) def test_return_validation_error_when_key_name_exists( client_request, @@ -35,7 +35,7 @@ def test_return_validation_error_when_key_name_exists( @pytest.mark.parametrize( - "key_type, expected_error", + ("key_type", "expected_error"), [("", "Select the type of key"), ("invalid", "Select the type of key")], ) def test_return_validation_error_when_key_type_not_chosen( diff --git a/tests/app/main/forms/test_placeholder_form.py b/tests/app/main/forms/test_placeholder_form.py index babd5c640..40a12ae56 100644 --- a/tests/app/main/forms/test_placeholder_form.py +++ b/tests/app/main/forms/test_placeholder_form.py @@ -24,7 +24,13 @@ def test_form_class_not_mutated(notify_admin): @pytest.mark.parametrize( - "service_can_send_international_sms, placeholder_name, template_type, value, expected_error", + ( + "service_can_send_international_sms", + "placeholder_name", + "template_type", + "value", + "expected_error", + ), [ (False, "email address", "email", "", "Cannot be empty"), (False, "email address", "email", "12345", "Enter a valid email address"), diff --git a/tests/app/main/forms/test_service_contact_details_form.py b/tests/app/main/forms/test_service_contact_details_form.py index 02695cb28..4521fe3bc 100644 --- a/tests/app/main/forms/test_service_contact_details_form.py +++ b/tests/app/main/forms/test_service_contact_details_form.py @@ -13,7 +13,7 @@ def test_form_fails_validation_with_no_radio_buttons_selected(notify_admin): @pytest.mark.parametrize( - "selected_radio_button, selected_text_box, text_box_data", + ("selected_radio_button", "selected_text_box", "text_box_data"), [ ("email_address", "url", "http://www.example.com"), ("phone_number", "url", "http://www.example.com"), @@ -40,7 +40,7 @@ def test_form_fails_validation_when_radio_button_selected_and_text_box_filled_in @pytest.mark.parametrize( - "selected_field, url, email_address, phone_number", + ("selected_field", "url", "email_address", "phone_number"), [ ("url", "http://www.example.com", "invalid-email.com", "phone"), ("email_address", "www.invalid-url.com", "me@example.com", "phone"), diff --git a/tests/app/main/forms/test_service_sms_senders_form.py b/tests/app/main/forms/test_service_sms_senders_form.py index fff10c5ca..4268b3c2d 100644 --- a/tests/app/main/forms/test_service_sms_senders_form.py +++ b/tests/app/main/forms/test_service_sms_senders_form.py @@ -4,7 +4,7 @@ from app.main.forms import ServiceSmsSenderForm @pytest.mark.parametrize( - "sms_sender,error_expected,error_message", + ("sms_sender", "error_expected", "error_message"), [ ("", True, "Cannot be empty"), ("22", True, "Enter 3 characters or more"), diff --git a/tests/app/main/forms/test_two_factor_form.py b/tests/app/main/forms/test_two_factor_form.py index 54eb1f6b7..4c9d583e2 100644 --- a/tests/app/main/forms/test_two_factor_form.py +++ b/tests/app/main/forms/test_two_factor_form.py @@ -30,8 +30,8 @@ def test_form_is_valid_returns_no_errors( @pytest.mark.parametrize( - "post_data, expected_error", - ( + ("post_data", "expected_error"), + [ ( {"sms_code": "1234"}, "Not enough numbers", @@ -52,7 +52,7 @@ def test_form_is_valid_returns_no_errors( {"sms_code": " ! 2 3 4 5 6"}, "Numbers only", ), - ), + ], ) def test_check_verify_code_returns_errors( notify_admin, diff --git a/tests/app/main/test_formatters.py b/tests/app/main/test_formatters.py index a77b182e4..e388db654 100644 --- a/tests/app/main/test_formatters.py +++ b/tests/app/main/test_formatters.py @@ -16,8 +16,8 @@ from app.formatters import ( @pytest.mark.parametrize( - "status, notification_type, expected", - ( + ("status", "notification_type", "expected"), + [ # Successful statuses aren’t linked ("created", "email", lambda: None), ("sending", "email", lambda: None), @@ -53,7 +53,7 @@ from app.formatters import ( "sms", partial(url_for, "main.message_status", _anchor="text-message-statuses"), ), - ), + ], ) def test_format_notification_status_as_url( client_request, @@ -65,7 +65,7 @@ def test_format_notification_status_as_url( @pytest.mark.parametrize( - "input_number, formatted_number", + ("input_number", "formatted_number"), [ (0, "0p"), (0.01, "1p"), @@ -84,7 +84,7 @@ def test_format_number_in_pounds_as_currency(input_number, formatted_number): @pytest.mark.parametrize( - "time, human_readable_datetime", + ("time", "human_readable_datetime"), [ # incoming in UTC, outgoing in "human formatted" UTC ("2018-03-14 09:00", "14 March at 09:00 UTC"), @@ -127,8 +127,8 @@ def test_format_datetime_relative(time, human_readable_datetime): @pytest.mark.parametrize( - "value, significant_figures, expected_result", - ( + ("value", "significant_figures", "expected_result"), + [ (0, 1, 0), (0, 2, 0), (12_345, 1, 10_000), @@ -138,14 +138,14 @@ def test_format_datetime_relative(time, human_readable_datetime): (12_345.6789, 1, 10_000), (12_345.6789, 9, 12_345), (-12_345, 1, -10_000), - ), + ], ) def test_round_to_significant_figures(value, significant_figures, expected_result): assert round_to_significant_figures(value, significant_figures) == expected_result @pytest.mark.parametrize( - "service_name, safe_email", + ("service_name", "safe_email"), [ ("name with spaces", "name.with.spaces"), ("singleword", "singleword"), diff --git a/tests/app/main/test_permissions.py b/tests/app/main/test_permissions.py index f2f015e27..a0104924e 100644 --- a/tests/app/main/test_permissions.py +++ b/tests/app/main/test_permissions.py @@ -15,8 +15,8 @@ from tests.conftest import ( @pytest.mark.parametrize( - "user_services, user_organizations, expected_status, organization_checked", - ( + ("user_services", "user_organizations", "expected_status", "organization_checked"), + [ ([SERVICE_ONE_ID], [], 200, False), ([SERVICE_ONE_ID, SERVICE_TWO_ID], [], 200, False), ([], [ORGANISATION_ID], 200, True), @@ -27,7 +27,7 @@ from tests.conftest import ( ([SERVICE_ONE_ID, SERVICE_TWO_ID], [ORGANISATION_ID], 200, False), ([], [ORGANISATION_TWO_ID], 403, True), ([], [ORGANISATION_ID, ORGANISATION_TWO_ID], 200, True), - ), + ], ) def test_services_pages_that_org_users_are_allowed_to_see( client_request, @@ -117,7 +117,7 @@ def test_service_navigation_for_org_user( @pytest.mark.parametrize( - "user_organizations, expected_menu_items, expected_status", + ("user_organizations", "expected_menu_items", "expected_status"), [ ( [], diff --git a/tests/app/main/test_request_header.py b/tests/app/main/test_request_header.py index 665ed689e..70d3d9ac9 100644 --- a/tests/app/main/test_request_header.py +++ b/tests/app/main/test_request_header.py @@ -4,7 +4,7 @@ from tests.conftest import set_config_values @pytest.mark.parametrize( - "check_proxy_header,header_value,expected_code", + ("check_proxy_header", "header_value,expected_code"), [ (True, "key_1", 200), (True, "wrong_key", 403), diff --git a/tests/app/main/test_validators.py b/tests/app/main/test_validators.py index d5962110e..09100f710 100644 --- a/tests/app/main/test_validators.py +++ b/tests/app/main/test_validators.py @@ -66,7 +66,7 @@ def test_sms_character_validation(client_request, msg): @pytest.mark.parametrize( - "data, err_msg", + ("data", "err_msg"), [ ( "∆ abc 📲 def 📵 ghi", diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index 6976b3aea..7d47c2a95 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -67,7 +67,7 @@ SAMPLE_DATA = { } -@pytest.fixture +@pytest.fixture() def mock_get_orgs_and_services(mocker): return mocker.patch( "app.user_api_client.get_organizations_and_services_for_user", @@ -177,8 +177,8 @@ def test_choose_account_should_show_choose_accounts_page_if_no_services( @pytest.mark.parametrize( - "orgs_and_services, expected_headings", - ( + ("orgs_and_services", "expected_headings"), + [ ( {"organizations": [], "services": []}, [ @@ -227,7 +227,7 @@ def test_choose_account_should_show_choose_accounts_page_if_no_services( "Trial mode services", ], ), - ), + ], ) def test_choose_account_should_should_organizations_link_for_platform_admin( client_request, @@ -302,10 +302,10 @@ def test_choose_account_should_not_show_back_to_service_link_if_not_signed_in( @pytest.mark.parametrize( "active", - ( + [ False, pytest.param(True), - ), + ], ) def test_choose_account_should_not_show_back_to_service_link_if_service_archived( client_request, diff --git a/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py b/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py index a57b582d2..d28d58f22 100644 --- a/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py +++ b/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py @@ -14,7 +14,7 @@ def user_with_orgs_and_services(num_orgs, num_services, platform_admin=False): @pytest.mark.parametrize( - "num_orgs,num_services,endpoint,endpoint_kwargs", + ("num_orgs", "num_services", "endpoint", "endpoint_kwargs"), [ (0, 0, ".choose_account", {}), (0, 2, ".choose_account", {}), diff --git a/tests/app/main/views/organizations/test_organization_invites.py b/tests/app/main/views/organizations/test_organization_invites.py index ac2e7fb56..3eca5ae49 100644 --- a/tests/app/main/views/organizations/test_organization_invites.py +++ b/tests/app/main/views/organizations/test_organization_invites.py @@ -256,24 +256,24 @@ def test_registration_from_org_invite_404s_if_user_not_in_session( @pytest.mark.parametrize( - "data, error", + ("data", "error"), [ - [ + ( { "name": "Bad Mobile", "mobile_number": "not good", "password": "validPassword!", }, "The string supplied did not seem to be a phone number", - ], - [ + ), + ( { "name": "Bad Password", "mobile_number": "+12021234123", "password": "password", }, "Choose a password that’s harder to guess", - ], + ), ], ) def test_registration_from_org_invite_has_bad_data( diff --git a/tests/app/main/views/organizations/test_organizations.py b/tests/app/main/views/organizations/test_organizations.py index 3abffc2fb..0b330b5a9 100644 --- a/tests/app/main/views/organizations/test_organizations.py +++ b/tests/app/main/views/organizations/test_organizations.py @@ -168,7 +168,7 @@ def test_create_new_organization_validates( @pytest.mark.parametrize( - "name, error_message", + ("name", "error_message"), [ ("", "Cannot be empty"), ("a", "at least two alphanumeric characters"), @@ -229,12 +229,12 @@ def test_create_new_organization_fails_with_duplicate_name( @pytest.mark.parametrize( - "organization_type, organization, expected_status", - ( + ("organization_type", "organization", "expected_status"), + [ ("nhs_gp", None, 200), ("central", None, 403), ("nhs_gp", organization_json(organization_type="nhs_gp"), 403), - ), + ], ) @pytest.mark.skip(reason="Update for TTS") def test_gps_can_create_own_organizations( @@ -265,8 +265,8 @@ def test_gps_can_create_own_organizations( @pytest.mark.parametrize( - "data, expected_service_name", - ( + ("data", "expected_service_name"), + [ ( { "same_as_service_name": False, @@ -281,7 +281,7 @@ def test_gps_can_create_own_organizations( }, "service one", ), - ), + ], ) @pytest.mark.skip(reason="Update for TTS") def test_gps_can_name_their_organization( @@ -315,8 +315,8 @@ def test_gps_can_name_their_organization( @pytest.mark.parametrize( - "data, expected_error", - ( + ("data", "expected_error"), + [ ( { "name": "Dr. Example", @@ -330,7 +330,7 @@ def test_gps_can_name_their_organization( }, "Cannot be empty", ), - ), + ], ) @pytest.mark.skip(reason="Update for TTS") def test_validation_of_gps_creating_organizations( @@ -457,12 +457,12 @@ def test_organization_services_shows_live_services_and_usage_with_count_of_1( @freeze_time("2020-02-20 20:20") @pytest.mark.parametrize( - "financial_year, expected_selected", - ( + ("financial_year", "expected_selected"), + [ (2017, "2017 to 2018 fiscal year"), (2018, "2018 to 2019 fiscal year"), (2019, "2019 to 2020 fiscal year"), - ), + ], ) def test_organization_services_filters_by_financial_year( client_request, @@ -784,10 +784,10 @@ def test_manage_org_users_shows_no_link_for_cancelled_users( @pytest.mark.parametrize( "number_of_users", - ( + [ pytest.param(8), pytest.param(800), - ), + ], ) def test_manage_org_users_should_show_live_search_if_more_than_7_users( client_request, @@ -831,10 +831,10 @@ def test_manage_org_users_should_show_live_search_if_more_than_7_users( @pytest.mark.parametrize( "number_of_users", - ( + [ pytest.param(3), pytest.param(7), - ), + ], ) def test_manage_org_users_should_show_live_search_if_7_users_or_less( client_request, @@ -947,8 +947,8 @@ def test_organization_settings_for_platform_admin( @pytest.mark.parametrize( - "endpoint, expected_options, expected_selected", - ( + ("endpoint", "expected_options", "expected_selected"), + [ ( ".edit_organization_type", ( @@ -958,16 +958,16 @@ def test_organization_settings_for_platform_admin( ), "federal", ), - ), + ], ) @pytest.mark.parametrize( "user", - ( + [ pytest.param( create_platform_admin_user(), ), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), - ), + ], ) def test_view_organization_settings( client_request, @@ -1007,8 +1007,8 @@ def test_view_organization_settings( @pytest.mark.parametrize( - "endpoint, post_data, expected_persisted", - ( + ("endpoint", "post_data", "expected_persisted"), + [ ( ".edit_organization_type", {"organization_type": "federal"}, @@ -1019,18 +1019,18 @@ def test_view_organization_settings( {"organization_type": "state"}, {"cached_service_ids": [], "organization_type": "state"}, ), - ), + ], ) @pytest.mark.parametrize( "user", - ( + [ pytest.param( create_platform_admin_user(), ), pytest.param( create_active_user_with_permissions(), ), - ), + ], ) def test_update_organization_settings( mocker, @@ -1101,12 +1101,12 @@ def test_update_organization_sector_sends_service_id_data_to_api_client( @pytest.mark.parametrize( "user", - ( + [ pytest.param( create_platform_admin_user(), ), pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), - ), + ], ) def test_view_organization_domains( mocker, @@ -1155,8 +1155,8 @@ def test_view_organization_domains( @pytest.mark.parametrize( - "post_data, expected_persisted", - ( + ("post_data", "expected_persisted"), + [ ( { "domains-0": "example.gsa.gov", @@ -1179,18 +1179,18 @@ def test_view_organization_domains( }, {"domains": []}, ), - ), + ], ) @pytest.mark.parametrize( "user", - ( + [ pytest.param( create_platform_admin_user(), ), pytest.param( create_active_user_with_permissions(), ), - ), + ], ) def test_update_organization_domains( client_request, @@ -1291,7 +1291,7 @@ def test_update_organization_name( @pytest.mark.parametrize( - "name, error_message", + ("name", "error_message"), [ ("", "Cannot be empty"), ("a", "at least two alphanumeric characters"), @@ -1362,7 +1362,8 @@ def test_get_edit_organization_go_live_notes_page( @pytest.mark.parametrize( - "input_note,saved_note", [("Needs permission", "Needs permission"), (" ", None)] + ("input_note", "saved_note"), + [("Needs permission", "Needs permission"), (" ", None)], ) def test_post_edit_organization_go_live_notes_updates_go_live_notes( client_request, diff --git a/tests/app/main/views/service_settings/test_email_branding_requests.py b/tests/app/main/views/service_settings/test_email_branding_requests.py index 55e7df8ee..ccab8a87a 100644 --- a/tests/app/main/views/service_settings/test_email_branding_requests.py +++ b/tests/app/main/views/service_settings/test_email_branding_requests.py @@ -9,15 +9,15 @@ from tests.conftest import ORGANISATION_ID, SERVICE_ONE_ID, normalize_spaces @pytest.mark.parametrize( - "organization_type, expected_options", - ( + ("organization_type", "expected_options"), + [ ( "other", [ ("something_else", "Something else"), ], ), - ), + ], ) def test_email_branding_request_page_when_no_branding_is_set( service_one, @@ -86,8 +86,8 @@ def test_email_branding_request_page_back_link( @pytest.mark.parametrize( - "data, org_type, endpoint", - ( + ("data", "org_type", "endpoint"), + [ ( { "options": "govuk", @@ -109,7 +109,7 @@ def test_email_branding_request_page_back_link( "federal", "main.email_branding_something_else", ), - ), + ], ) def test_email_branding_request_submit( client_request, @@ -162,7 +162,7 @@ def test_email_branding_request_submit_when_no_radio_button_is_selected( @pytest.mark.parametrize( - "endpoint, expected_heading", + ("endpoint", "expected_heading"), [ ("main.email_branding_govuk_and_org", "Before you request new branding"), ], @@ -196,11 +196,8 @@ def test_email_branding_description_pages_for_org_branding( @pytest.mark.parametrize( - "endpoint, service_org_type, branding_preview_id", - [ - ("main.email_branding_govuk", "central", "__NONE__"), - # ('main.email_branding_nhs', 'nhs_local', NHS_EMAIL_BRANDING_ID), - ], + ("endpoint", "service_org_type", "branding_preview_id"), + [("main.email_branding_govuk", "central", "__NONE__")], ) @pytest.mark.skip(reason="Update for TTS") def test_email_branding_govuk_and_nhs_pages( diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index f2673cb15..42c50b8be 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -7,7 +7,7 @@ from app.main.views.service_settings import PLATFORM_ADMIN_SERVICE_PERMISSIONS from tests.conftest import normalize_spaces -@pytest.fixture +@pytest.fixture() def get_service_settings_page( client_request, platform_admin_user, @@ -41,7 +41,7 @@ def test_service_set_permission_requires_platform_admin( @pytest.mark.parametrize( - "initial_permissions, permission, form_data, expected_update", + ("initial_permissions", "permission", "form_data", "expected_update"), [ ( [], @@ -102,7 +102,7 @@ def test_service_set_permission( @pytest.mark.parametrize( - "service_fields, endpoint, kwargs, text", + ("service_fields", "endpoint", "kwargs", "text"), [ ( {"restricted": True}, @@ -146,7 +146,7 @@ def test_service_setting_toggles_show( @pytest.mark.parametrize( - "service_fields, endpoint, index, text", + ("service_fields", "endpoint", "index", "text"), [ ({"active": True}, ".archive_service", 0, "Delete this service"), ({"active": True}, ".suspend_service", 1, "Suspend service"), @@ -172,7 +172,7 @@ def test_service_setting_link_toggles( @pytest.mark.parametrize( - "service_fields, endpoint, index, text", + ("service_fields", "endpoint", "index", "text"), [ pytest.param( {"active": False}, @@ -190,7 +190,9 @@ def test_service_setting_link_toggles_index_error( index, text, ): - with pytest.raises(expected_exception=IndexError): + with pytest.raises( # noqa: PT012 # Requires more research to refactor. + expected_exception=IndexError + ): url_for(endpoint, service_id=service_one["id"]) service_one.update(service_fields) page = get_service_settings_page() @@ -198,7 +200,7 @@ def test_service_setting_link_toggles_index_error( @pytest.mark.parametrize( - "permissions,permissions_text,visible", + ("permissions", "permissions_text,visible"), [ ("sms", "inbound SMS", True), ("inbound_sms", "inbound SMS", False), # no sms parent permission @@ -216,7 +218,7 @@ def test_service_settings_doesnt_show_option_if_parent_permission_disabled( @pytest.mark.parametrize( - "service_fields, link_text", + ("service_fields", "link_text"), [ # can't archive or suspend inactive service. Can't resume active service. ({"active": False}, "Archive service"),