-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
113 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,24 +16,17 @@ def _index_rows(rows): | |
@pytest.mark.parametrize( | ||
"file_contents,template_type,expected,user_language", | ||
[ | ||
( | ||
"", | ||
"sms", | ||
[], "en" | ||
), | ||
( | ||
"phone number", | ||
"sms", | ||
[], "fr" | ||
), | ||
("", "sms", [], "en"), | ||
("phone number", "sms", [], "fr"), | ||
( | ||
""" | ||
phone number,name | ||
+1 123, test1 | ||
+1 456,test2 | ||
""", | ||
"sms", | ||
[[("phone number", "+1 123"), ("name", "test1")], [("phone number", "+1 456"), ("name", "test2")]], "en" | ||
[[("phone number", "+1 123"), ("name", "test1")], [("phone number", "+1 456"), ("name", "test2")]], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -42,7 +35,8 @@ def _index_rows(rows): | |
+1 456 | ||
""", | ||
"sms", | ||
[[("phone number", "+1 123"), ("name", None)], [("phone number", "+1 456"), ("name", None)]], "en" | ||
[[("phone number", "+1 123"), ("name", None)], [("phone number", "+1 456"), ("name", None)]], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -54,7 +48,8 @@ def _index_rows(rows): | |
[ | ||
[("email address", "[email protected]"), ("name", "test1")], | ||
[("email address", "[email protected]"), ("name", "test2")], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -66,7 +61,8 @@ def _index_rows(rows): | |
[ | ||
[("email address", "[email protected]"), (None, ["test1", "red"])], | ||
[("email address", "[email protected]"), (None, ["test2", "blue"])], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -80,7 +76,8 @@ def _index_rows(rows): | |
[("email address", "[email protected]"), ("name", "test1")], | ||
[("email address", "[email protected]"), ("name", "test2")], | ||
[("email address", "[email protected]"), ("name", "test3")], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -92,7 +89,8 @@ def _index_rows(rows): | |
[ | ||
[("email address", "[email protected]"), ("date", "Nov 28, 2016"), ("name", "test1")], | ||
[("email address", "[email protected]"), ("date", "Nov 29, 2016"), ("name", "test2")], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -106,7 +104,8 @@ def _index_rows(rows): | |
[("phone number", "07900900001"), ("list", ["cat", "rat", "gnat"])], | ||
[("phone number", "07900900002"), ("list", ["dog", "hog", "frog"])], | ||
[("phone number", "07900900003"), ("list", ["elephant", None, None])], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -118,7 +117,8 @@ def _index_rows(rows): | |
[ | ||
[("address courriel", "[email protected]"), ("name", "test1")], | ||
[("address courriel", "[email protected]"), ("name", "test2")], | ||
], "fr" | ||
], | ||
"fr", | ||
), | ||
( | ||
""" | ||
|
@@ -132,9 +132,10 @@ def _index_rows(rows): | |
[("numéro de téléphone", "07900900001"), ("list", ["cat", "rat", "gnat"])], | ||
[("numéro de téléphone", "07900900002"), ("list", ["dog", "hog", "frog"])], | ||
[("numéro de téléphone", "07900900003"), ("list", ["elephant", None, None])], | ||
], "fr" | ||
], | ||
"fr", | ||
), | ||
( | ||
( | ||
""" | ||
numéro de téléphone, list, list, list | ||
07900900001, cat, rat, gnat | ||
|
@@ -146,7 +147,8 @@ def _index_rows(rows): | |
[("numéro de téléphone", "07900900001"), ("list", ["cat", "rat", "gnat"])], | ||
[("numéro de téléphone", "07900900002"), ("list", ["dog", "hog", "frog"])], | ||
[("numéro de téléphone", "07900900003"), ("list", ["elephant", None, None])], | ||
], "en" | ||
], | ||
"en", | ||
), | ||
], | ||
) | ||
|
@@ -411,9 +413,22 @@ def test_get_recipient_respects_order(file_contents, template_type, placeholders | |
|
||
|
||
@pytest.mark.parametrize( | ||
"file_contents,template_type,expected,expected_missing", | ||
"file_contents,template_type,expected,expected_missing, user_language", | ||
[ | ||
("", "sms", [], set(["phone number", "name"])), | ||
("", "sms", [], set(["phone number", "name"]), "en"), | ||
("", "email", [], set(["email address", "name"]), "en"), | ||
( | ||
""" | ||
numéro de téléphone, name | ||
6502532222,test1 | ||
6502532222,test1 | ||
6502532222,test1 | ||
""", | ||
"sms", | ||
["numéro de téléphone", "name"], | ||
set(), | ||
"fr", | ||
), | ||
( | ||
""" | ||
phone number,name | ||
|
@@ -424,6 +439,7 @@ def test_get_recipient_respects_order(file_contents, template_type, placeholders | |
"sms", | ||
["phone number", "name"], | ||
set(), | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -432,6 +448,7 @@ def test_get_recipient_respects_order(file_contents, template_type, placeholders | |
"email", | ||
["email address", "name", "colour"], | ||
set(), | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -440,6 +457,7 @@ def test_get_recipient_respects_order(file_contents, template_type, placeholders | |
"email", | ||
["email address", "colour"], | ||
set(["name"]), | ||
"en", | ||
), | ||
( | ||
""" | ||
|
@@ -448,11 +466,33 @@ def test_get_recipient_respects_order(file_contents, template_type, placeholders | |
"sms", | ||
["phone number", "list", "name"], | ||
set(), | ||
"en", | ||
), | ||
( | ||
""" | ||
numéro de téléphone,list,list,name,list | ||
""", | ||
"sms", | ||
["numéro de téléphone", "list", "name"], | ||
set(), | ||
"en", | ||
), | ||
( | ||
""" | ||
list,list,name,list | ||
""", | ||
"sms", | ||
[ | ||
"list", | ||
"name", | ||
], | ||
set(["numéro de téléphone"]), | ||
"fr", | ||
), | ||
], | ||
) | ||
def test_column_headers(file_contents, template_type, expected, expected_missing): | ||
recipients = RecipientCSV(file_contents, template_type=template_type, placeholders=["name"]) | ||
def test_column_headers(file_contents, template_type, expected, expected_missing, user_language): | ||
recipients = RecipientCSV(file_contents, template_type=template_type, placeholders=["name"], user_language=user_language) | ||
assert recipients.column_headers == expected | ||
assert recipients.missing_column_headers == expected_missing | ||
assert recipients.has_errors == bool(expected_missing) | ||
|
@@ -473,7 +513,6 @@ def test_column_headers(file_contents, template_type, expected, expected_missing | |
("email_address", "email"), | ||
("adresse courriel", "email"), | ||
("numéro de téléphone", "sms"), | ||
("numero de telephone", "sms") | ||
], | ||
) | ||
def test_recipient_column(placeholders, file_contents, template_type): | ||
|