More formatting fixes for tests

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2023-09-06 18:29:04 -04:00
parent 47695b97d3
commit 95ba7c3099
7 changed files with 41 additions and 35 deletions

View File

@@ -4,7 +4,7 @@ from app.utils import merge_jsonlike
@pytest.mark.parametrize( @pytest.mark.parametrize(
"source_object, destination_object, expected_result", ("source_object", "destination_object", "expected_result"),
[ [
# simple dicts: # simple dicts:
({"a": "b"}, {"c": "d"}, {"a": "b", "c": "d"}), ({"a": "b"}, {"c": "d"}, {"a": "b", "c": "d"}),

View File

@@ -10,7 +10,7 @@ from tests.conftest import create_email_branding
@pytest.mark.parametrize("function", [get_email_choices]) @pytest.mark.parametrize("function", [get_email_choices])
@pytest.mark.parametrize( @pytest.mark.parametrize(
"org_type, expected_options", ("org_type", "expected_options"),
[ [
("federal", []), ("federal", []),
("state", []), ("state", []),
@@ -30,7 +30,7 @@ def test_get_choices_service_not_assigned_to_org(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"org_type, branding_id, expected_options", ("org_type", "branding_id", "expected_options"),
[ [
( (
"federal", "federal",
@@ -86,7 +86,7 @@ def test_get_email_choices_service_assigned_to_org(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"org_type, branding_id, expected_options", ("org_type", "branding_id", "expected_options"),
[ [
( (
"federal", "federal",
@@ -141,7 +141,7 @@ def test_get_email_choices_org_has_default_branding(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"branding_name, expected_options", ("branding_name", "expected_options"),
[ [
( (
"gsa.gov and something else", "gsa.gov and something else",

View File

@@ -65,8 +65,8 @@ def _get_notifications_csv(
return _get return _get
@pytest.fixture(scope="function") @pytest.fixture()
def _get_notifications_csv_mock( def get_notifications_csv_mock(
mocker, mocker,
api_user_active, api_user_active,
): ):
@@ -77,7 +77,7 @@ def _get_notifications_csv_mock(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"created_by_name, expected_content", ("created_by_name", "expected_content"),
[ [
( (
None, None,
@@ -114,7 +114,7 @@ def test_generate_notifications_csv_without_job(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"original_file_contents, expected_column_headers, expected_1st_row", ("original_file_contents", "expected_column_headers", "expected_1st_row"),
[ [
( (
""" """
@@ -211,7 +211,7 @@ def test_generate_notifications_csv_without_job(
def test_generate_notifications_csv_returns_correct_csv_file( def test_generate_notifications_csv_returns_correct_csv_file(
notify_admin, notify_admin,
mocker, mocker,
_get_notifications_csv_mock, get_notifications_csv_mock,
original_file_contents, original_file_contents,
expected_column_headers, expected_column_headers,
expected_1st_row, expected_1st_row,
@@ -231,11 +231,11 @@ def test_generate_notifications_csv_returns_correct_csv_file(
def test_generate_notifications_csv_only_calls_once_if_no_next_link( def test_generate_notifications_csv_only_calls_once_if_no_next_link(
notify_admin, notify_admin,
_get_notifications_csv_mock, get_notifications_csv_mock,
): ):
list(generate_notifications_csv(service_id="1234")) list(generate_notifications_csv(service_id="1234"))
assert _get_notifications_csv_mock.call_count == 1 assert get_notifications_csv_mock.call_count == 1
@pytest.mark.parametrize("job_id", ["some", None]) @pytest.mark.parametrize("job_id", ["some", None])
@@ -303,8 +303,14 @@ MockRecipients = namedtuple(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"rows_with_bad_recipients, rows_with_missing_data, " (
"rows_with_message_too_long, rows_with_empty_message, template_type, expected_errors", "rows_with_bad_recipients",
"rows_with_missing_data",
"rows_with_message_too_long",
"rows_with_empty_message",
"template_type",
"expected_errors",
),
[ [
([], [], [], [], "sms", []), ([], [], [], [], "sms", []),
({2}, [], [], [], "sms", ["fix 1 phone number"]), ({2}, [], [], [], "sms", ["fix 1 phone number"]),

View File

@@ -8,10 +8,10 @@ from app.utils.login import email_needs_revalidating
@freeze_time("2020-11-27T12:00:00") @freeze_time("2020-11-27T12:00:00")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("email_access_validated_at", "expected_result"), ("email_access_validated_at", "expected_result"),
( [
("2020-10-01T11:35:21.726132Z", False), ("2020-10-01T11:35:21.726132Z", False),
("2020-07-23T11:35:21.726132Z", True), ("2020-07-23T11:35:21.726132Z", True),
), ],
) )
def test_email_needs_revalidating( def test_email_needs_revalidating(
api_user_active, api_user_active,

View File

@@ -5,7 +5,7 @@ from app.utils.time import get_current_financial_year, is_less_than_days_ago
@pytest.mark.parametrize( @pytest.mark.parametrize(
"date_from_db, expected_result", ("date_from_db", "expected_result"),
[ [
("2019-11-17T11:35:21.726132Z", True), ("2019-11-17T11:35:21.726132Z", True),
("2019-11-16T11:35:21.726132Z", False), ("2019-11-16T11:35:21.726132Z", False),
@@ -18,13 +18,13 @@ def test_is_less_than_days_ago(date_from_db, expected_result):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"datetime_string, financial_year", ("datetime_string", "financial_year"),
( [
("2021-01-01T00:00:00+00:00", 2020), # Start of 2021 ("2021-01-01T00:00:00+00:00", 2020), # Start of 2021
("2021-04-01T03:59:59+00:00", 2020), # One minute before midnight (BST) ("2021-04-01T03:59:59+00:00", 2020), # One minute before midnight (BST)
("2021-10-01T04:05:00+00:00", 2021), # Midnight (BST) ("2021-10-01T04:05:00+00:00", 2021), # Midnight (BST)
("2021-12-12T12:12:12+01:00", 2021), # Later in the year ("2021-12-12T12:12:12+01:00", 2021), # Later in the year
), ],
) )
def test_get_financial_year(datetime_string, financial_year): def test_get_financial_year(datetime_string, financial_year):
with freeze_time(datetime_string): with freeze_time(datetime_string):

View File

@@ -7,25 +7,25 @@ from app.utils.user import user_has_permissions
@pytest.mark.parametrize( @pytest.mark.parametrize(
"permissions", "permissions",
( [
[ (
# Route has one of the permissions which the user has # Route has one of the permissions which the user has
"manage_service" "manage_service"
], ),
[ (
# Route has more than one of the permissions which the user has # Route has more than one of the permissions which the user has
"manage_templates", "manage_templates",
"manage_service", "manage_service",
], ),
[ (
# Route has one of the permissions which the user has, and one they do not # Route has one of the permissions which the user has, and one they do not
"manage_service", "manage_service",
"send_messages", "send_messages",
], ),
[ (
# Route has no specific permissions required # Route has no specific permissions required
], ),
), ],
) )
def test_permissions( def test_permissions(
client_request, client_request,
@@ -50,12 +50,12 @@ def test_permissions(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"permissions", "permissions",
( [
[ (
# Route has a permission which the user doesnt have # Route has a permission which the user doesnt have
"send_messages" "send_messages"
], ),
), ],
) )
def test_permissions_forbidden( def test_permissions_forbidden(
client_request, client_request,

View File

@@ -7,7 +7,7 @@ from app.utils.user_permissions import (
@pytest.mark.parametrize( @pytest.mark.parametrize(
"db_permissions,expected_ui_permissions", ("db_permissions", "expected_ui_permissions"),
[ [
( (
["manage_templates"], ["manage_templates"],