mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
ensure robustness of email_safe function
* remove leading, trailing, or consecutive periods * strip unicode accents, umlauts, diacritics etc
This commit is contained in:
@@ -8,11 +8,20 @@ from freezegun import freeze_time
|
||||
from app.utils import email_safe, generate_notifications_csv, generate_previous_dict, generate_next_dict, Spreadsheet
|
||||
|
||||
|
||||
def test_email_safe_return_dot_separated_email_domain():
|
||||
test_name = 'SOME service with+stuff+ b123'
|
||||
expected = 'some.service.withstuff.b123'
|
||||
actual = email_safe(test_name)
|
||||
assert actual == expected
|
||||
@pytest.mark.parametrize('service_name, safe_email', [
|
||||
('name with spaces', 'name.with.spaces'),
|
||||
('singleword', 'singleword'),
|
||||
('UPPER CASE', 'upper.case'),
|
||||
('Service - with dash', 'service.with.dash'),
|
||||
('lots of spaces', 'lots.of.spaces'),
|
||||
('name.with.dots', 'name.with.dots'),
|
||||
('name-with-other-delimiters', 'namewithotherdelimiters'),
|
||||
('.leading', 'leading'),
|
||||
('trailing.', 'trailing'),
|
||||
('üńïçödë wördś', 'unicode.words'),
|
||||
])
|
||||
def test_email_safe_return_dot_separated_email_domain(service_name, safe_email):
|
||||
assert email_safe(service_name) == safe_email
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user