mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-10 05:14:05 -05:00
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```
Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.
Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
lib1,
lib2,
lib3,
lib4,
)
```
1. https://pypi.python.org/pypi/isort
71 lines
1.4 KiB
Python
71 lines
1.4 KiB
Python
from collections import namedtuple
|
|
|
|
import pytest
|
|
|
|
from app.utils import get_errors_for_csv
|
|
|
|
MockRecipients = namedtuple(
|
|
'RecipientCSV',
|
|
[
|
|
'rows_with_bad_recipients',
|
|
'rows_with_missing_data'
|
|
]
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"rows_with_bad_recipients,rows_with_missing_data,template_type,expected_errors",
|
|
[
|
|
(
|
|
[], [],
|
|
'sms',
|
|
[]
|
|
),
|
|
(
|
|
{2}, [],
|
|
'sms',
|
|
['fix 1 phone number']
|
|
),
|
|
(
|
|
{2, 4, 6}, [],
|
|
'sms',
|
|
['fix 3 phone numbers']
|
|
),
|
|
(
|
|
{1}, [],
|
|
'email',
|
|
['fix 1 email address']
|
|
),
|
|
(
|
|
{2, 4, 6}, [],
|
|
'email',
|
|
['fix 3 email addresses']
|
|
),
|
|
(
|
|
{2}, {3},
|
|
'sms',
|
|
[
|
|
'fix 1 phone number',
|
|
'enter missing data in 1 row'
|
|
]
|
|
),
|
|
(
|
|
{2, 4, 6, 8}, {3, 6, 9, 12},
|
|
'sms',
|
|
[
|
|
'fix 4 phone numbers',
|
|
'enter missing data in 4 rows'
|
|
]
|
|
)
|
|
]
|
|
)
|
|
def test_get_errors_for_csv(
|
|
rows_with_bad_recipients, rows_with_missing_data,
|
|
template_type,
|
|
expected_errors
|
|
):
|
|
assert get_errors_for_csv(
|
|
MockRecipients(rows_with_bad_recipients, rows_with_missing_data),
|
|
template_type
|
|
) == expected_errors
|