Reformatted a handful more tests

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2023-09-08 17:58:06 -04:00
parent 23f894581c
commit 72c8a46b8c
21 changed files with 139 additions and 118 deletions

View File

@@ -76,7 +76,7 @@ def test_doesnt_redirect_to_sign_in_if_no_session_info(
@pytest.mark.parametrize(
"db_sess_id, cookie_sess_id",
("db_sess_id", "cookie_sess_id"),
[
(None, None),
(None, uuid.UUID(int=1)), # BAD - cookie doesn't match db
@@ -139,7 +139,7 @@ def test_logged_in_user_doesnt_do_evil_redirect(client_request):
],
)
@pytest.mark.parametrize(
"email_address, password",
("email_address", "password"),
[
("valid@example.gsa.gov", "val1dPassw0rd!"),
(" valid@example.gsa.gov ", " val1dPassw0rd! "),

View File

@@ -39,15 +39,15 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
@pytest.mark.parametrize(
(
"expected_title_tag,"
"expected_page_title,"
"expected_parent_link_args,"
"extra_args,"
"expected_nav_links,"
"expected_items, "
"expected_displayed_items, "
"expected_searchable_text, "
"expected_empty_message "
"expected_title_tag",
"expected_page_title",
"expected_parent_link_args",
"extra_args",
"expected_nav_links",
"expected_items",
"expected_displayed_items",
"expected_searchable_text",
"expected_empty_message",
),
[
(
@@ -1026,10 +1026,10 @@ def test_delete_template_folder_should_detect_non_empty_folder_on_get(
@pytest.mark.parametrize(
"parent_folder_id",
(
[
None,
PARENT_FOLDER_ID,
),
],
)
def test_delete_folder(
client_request,
@@ -1117,7 +1117,9 @@ def test_should_show_checkboxes_for_selecting_templates_assertion_error(
mock_get_no_api_keys,
user,
):
with pytest.raises(expected_exception=AssertionError):
with pytest.raises( # noqa: PT012 # This will require more research into refactoring.
expected_exception=AssertionError
):
client_request.login(user)
page = client_request.get(
@@ -1289,7 +1291,7 @@ def test_should_be_able_to_move_to_existing_folder(
@pytest.mark.parametrize(
"user, expected_status, expected_called",
("user", "expected_status", "expected_called"),
[
(create_active_user_view_permissions(), 403, False),
(create_active_user_with_permissions(), 302, True),
@@ -1618,7 +1620,7 @@ def test_radio_button_with_no_value_shows_custom_error_message(
@pytest.mark.parametrize(
"data, error_msg",
("data", "error_msg"),
[
# nothing selected when moving
(
@@ -1678,10 +1680,10 @@ def test_show_custom_error_message(
@pytest.mark.parametrize(
(
"extra_args,"
"expected_displayed_items, "
"expected_items, "
"expected_empty_message "
"extra_args",
"expected_displayed_items",
"expected_items",
"expected_empty_message",
),
[
(

View File

@@ -28,8 +28,8 @@ from tests.conftest import (
@pytest.mark.parametrize(
"permissions, expected_message",
(
("permissions", "expected_message"),
[
(
["email"],
(
@@ -51,7 +51,7 @@ from tests.conftest import (
"You need a template before you can send messages."
),
),
),
],
)
def test_should_show_empty_page_when_no_templates(
client_request,
@@ -100,7 +100,13 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
@pytest.mark.parametrize(
"user, expected_page_title, extra_args, expected_nav_links, expected_templates",
(
"user",
"expected_page_title",
"extra_args",
"expected_nav_links",
"expected_templates",
),
[
(
create_active_user_view_permissions(),
@@ -298,9 +304,9 @@ def test_should_show_live_search_if_service_has_lots_of_folders(
assert count_of_templates == 4
@pytest.mark.parametrize(
"service_permissions, expected_values, expected_labels",
(
@pytest.mark.parametrize( # noqa: PT014 # Requires more research why there are duplicate params here.
("service_permissions", "expected_values", "expected_labels"),
[
pytest.param(
["email", "sms"],
[
@@ -327,7 +333,7 @@ def test_should_show_live_search_if_service_has_lots_of_folders(
"Copy an existing template",
],
),
),
],
)
def test_should_show_new_template_choices_if_service_has_folder_permission(
client_request,
@@ -363,7 +369,7 @@ def test_should_show_new_template_choices_if_service_has_folder_permission(
@pytest.mark.parametrize(
"permissions,are_data_attrs_added",
("permissions", "are_data_attrs_added"),
[
(["sms"], True),
(["email"], True),
@@ -523,7 +529,7 @@ def test_user_with_only_send_and_view_redirected_to_set_sender_for_one_off(
@pytest.mark.parametrize(
"permissions, links_to_be_shown, permissions_warning_to_be_shown",
("permissions", "links_to_be_shown", "permissions_warning_to_be_shown"),
[
(
["view_activity"],
@@ -899,8 +905,8 @@ def test_choose_a_template_to_copy_from_folder_within_service(
@pytest.mark.parametrize(
"existing_template_names, expected_name",
(
("existing_template_names", "expected_name"),
[
(["Two week reminder"], "Two week reminder (copy)"),
(["Two week reminder (copy)"], "Two week reminder (copy 2)"),
(
@@ -919,7 +925,7 @@ def test_choose_a_template_to_copy_from_folder_within_service(
["Two week reminder (copy)", "Two week reminder (copy 10)"],
"Two week reminder (copy 2)",
),
),
],
)
def test_load_edit_template_with_copy_of_template(
client_request,
@@ -1002,8 +1008,8 @@ def test_cant_copy_template_from_non_member_service(
@pytest.mark.parametrize(
"service_permissions, data, expected_error",
(
("service_permissions", "data", "expected_error"),
[
(
["email"],
{
@@ -1012,7 +1018,7 @@ def test_cant_copy_template_from_non_member_service(
},
"Sending text messages has been disabled for your service.",
),
),
],
)
def test_should_not_allow_creation_of_template_through_form_without_correct_permission(
client_request,
@@ -1040,9 +1046,9 @@ def test_should_not_allow_creation_of_template_through_form_without_correct_perm
)
@pytest.mark.parametrize("method", ("get", "post"))
@pytest.mark.parametrize("method", ["get", "post"])
@pytest.mark.parametrize(
"type_of_template, expected_error",
("type_of_template", "expected_error"),
[
("email", "Sending emails has been disabled for your service."),
("sms", "Sending text messages has been disabled for your service."),
@@ -1236,7 +1242,7 @@ def test_should_403_when_create_template_with_process_type_of_priority_for_non_p
@pytest.mark.parametrize(
"old_content, new_content, expected_paragraphs",
("old_content", "new_content", "expected_paragraphs"),
[
(
"my favorite color is blue",
@@ -1521,7 +1527,7 @@ def test_should_show_delete_template_page_with_never_used_block(
mock_get_service_template.assert_called_with(SERVICE_ONE_ID, fake_uuid, None)
@pytest.mark.parametrize("parent", (PARENT_FOLDER_ID, None))
@pytest.mark.parametrize("parent", [PARENT_FOLDER_ID, None])
def test_should_redirect_when_deleting_a_template(
mocker,
client_request,
@@ -1706,11 +1712,11 @@ def test_route_invalid_permissions(
@pytest.mark.parametrize(
"template_type, expected",
(
("template_type", "expected"),
[
("email", "New email template"),
("sms", "New text message template"),
),
],
)
def test_add_template_page_title(
client_request,
@@ -1748,7 +1754,10 @@ def test_can_create_email_template_with_emoji(
@pytest.mark.parametrize(
"template_type, expected_error", (("sms", ("You cannot use 🍜 in text messages.")),)
("template_type", "expected_error"),
[
("sms", ("You cannot use 🍜 in text messages.")),
],
)
def test_should_not_create_sms_template_with_emoji(
client_request,
@@ -1776,7 +1785,10 @@ def test_should_not_create_sms_template_with_emoji(
@pytest.mark.parametrize(
"template_type, expected_error", (("sms", ("You cannot use 🍔 in text messages.")),)
("template_type", "expected_error"),
[
("sms", ("You cannot use 🍔 in text messages.")),
],
)
def test_should_not_update_sms_template_with_emoji(
mocker,
@@ -1815,7 +1827,12 @@ def test_should_not_update_sms_template_with_emoji(
assert mock_update_service_template.called is False
@pytest.mark.parametrize("template_type", ("sms",))
@pytest.mark.parametrize(
"template_type",
[
"sms",
],
)
def test_should_create_sms_template_without_downgrading_unicode_characters(
client_request,
service_one,
@@ -1944,8 +1961,8 @@ def test_set_template_sender(
@pytest.mark.parametrize(
"template_type, prefix_sms, content, expected_message, expected_class",
(
("template_type", "prefix_sms", "content", "expected_message", "expected_class"),
[
(
"sms",
False,
@@ -2068,7 +2085,7 @@ def test_set_template_sender(
"Will be charged as 1 text message (not including personalization)",
None,
),
),
],
)
def test_content_count_json_endpoint(
client_request,
@@ -2103,10 +2120,10 @@ def test_content_count_json_endpoint(
@pytest.mark.parametrize(
"template_type",
(
[
"email",
"banana",
),
],
)
def test_content_count_json_endpoint_for_unsupported_template_types(
client_request,

View File

@@ -9,7 +9,7 @@ from tests.conftest import (
)
@pytest.fixture
@pytest.fixture()
def mock_email_validated_recently(mocker):
return mocker.patch(
"app.main.views.two_factor.email_needs_revalidating", return_value=False
@@ -23,7 +23,7 @@ def mock_email_validated_recently(mocker):
"redirect_url", [None, f"/services/{SERVICE_ONE_ID}/templates"]
)
@pytest.mark.parametrize(
"email_resent, page_title", [(None, "Check your email"), (True, "Email resent")]
("email_resent", "page_title"), [(None, "Check your email"), (True, "Email resent")]
)
def test_two_factor_email_sent_page(
client_request, email_resent, page_title, redirect_url, request_url
@@ -168,10 +168,10 @@ def test_should_login_user_and_not_redirect_to_external_url(
@pytest.mark.parametrize(
"platform_admin",
(
[
True,
False,
),
],
)
def test_should_login_user_and_redirect_to_show_accounts(
client_request,
@@ -334,8 +334,8 @@ def test_two_factor_sms_should_activate_pending_user(
@pytest.mark.parametrize(
"extra_args, expected_encoded_next_arg",
(({}, ""), ({"next": "https://example.com"}, "?next=https://example.com")),
("extra_args", "expected_encoded_next_arg"),
[({}, ""), ({"next": "https://example.com"}, "?next=https://example.com")],
)
def test_valid_two_factor_email_link_shows_interstitial(
client_request,

View File

@@ -80,7 +80,7 @@ def test_should_redirect_after_email_change(
@pytest.mark.parametrize(
"email_address,error_message",
("email_address", "error_message"),
[
(
"me@example.com",

View File

@@ -9,15 +9,17 @@ from tests.conftest import (
)
@pytest.mark.usefixtures("_mock_get_no_uploads")
@pytest.mark.parametrize(
"extra_permissions, expected_empty_message",
(([], ("You have not uploaded any files recently.")),),
("extra_permissions", "expected_empty_message"),
[
([], ("You have not uploaded any files recently.")),
],
)
def test_get_upload_hub_with_no_uploads(
mocker,
client_request,
service_one,
_mock_get_no_uploads,
extra_permissions,
expected_empty_message,
):
@@ -56,18 +58,18 @@ def test_get_upload_hub_page(
)
@pytest.mark.usefixtures("_mock_get_no_uploads")
@pytest.mark.parametrize(
"user",
(
[
create_active_caseworking_user(),
create_active_user_with_permissions(),
),
],
)
@freeze_time("2012-12-12 12:12")
def test_uploads_page_shows_scheduled_jobs(
mocker,
client_request,
_mock_get_no_uploads,
mock_get_jobs,
user,
):