Validate CSVs against rows with empty messages

This commit is contained in:
Pea Tyczynska
2019-11-21 12:12:04 +00:00
parent 512094c52c
commit f265dde8ab
6 changed files with 205 additions and 12 deletions

View File

@@ -8,41 +8,44 @@ MockRecipients = namedtuple(
'RecipientCSV',
[
'rows_with_bad_recipients',
'rows_with_missing_data'
'rows_with_missing_data',
'rows_with_message_too_long',
'rows_with_empty_message'
]
)
@pytest.mark.parametrize(
"rows_with_bad_recipients,rows_with_missing_data,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',
[]
),
(
{2}, [],
{2}, [], [], [],
'sms',
['fix 1 phone number']
),
(
{2, 4, 6}, [],
{2, 4, 6}, [], [], [],
'sms',
['fix 3 phone numbers']
),
(
{1}, [],
{1}, [], [], [],
'email',
['fix 1 email address']
),
(
{2, 4, 6}, [],
{2, 4, 6}, [], [], [],
'email',
['fix 3 email addresses']
),
(
{2}, {3},
{2}, {3}, [], [],
'sms',
[
'fix 1 phone number',
@@ -50,21 +53,35 @@ MockRecipients = namedtuple(
]
),
(
{2, 4, 6, 8}, {3, 6, 9, 12},
{2, 4, 6, 8}, {3, 6, 9, 12}, [], [],
'sms',
[
'fix 4 phone numbers',
'enter missing data in 4 rows'
]
)
),
(
{}, {}, {3}, [],
'sms',
[
'shorten your message in 1 row'
]
),
(
{}, {}, {}, {2},
'sms',
[
'add content to empty message in 1 row'
]
),
]
)
def test_get_errors_for_csv(
rows_with_bad_recipients, rows_with_missing_data,
rows_with_bad_recipients, rows_with_missing_data, rows_with_message_too_long, rows_with_empty_message,
template_type,
expected_errors
):
assert get_errors_for_csv(
MockRecipients(rows_with_bad_recipients, rows_with_missing_data),
MockRecipients(rows_with_bad_recipients, rows_with_missing_data, rows_with_message_too_long, rows_with_empty_message),
template_type
) == expected_errors