mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this. Areas affected: - Things obviously about letters - PDF tasks, used for precompiling letters - Virus scanning, used for those PDFs - FTP, used to send letters to the printer - Postage stuff
This commit is contained in:
@@ -19,38 +19,33 @@ NewStatsRow = collections.namedtuple('row', ('notification_type', 'status', 'key
|
||||
|
||||
|
||||
# email_counts and sms_counts are 3-tuple of requested, delivered, failed
|
||||
@pytest.mark.idparametrize('stats, email_counts, sms_counts, letter_counts', {
|
||||
'empty': ([], [0, 0, 0], [0, 0, 0], [0, 0, 0]),
|
||||
@pytest.mark.idparametrize('stats, email_counts, sms_counts', {
|
||||
'empty': ([], [0, 0, 0], [0, 0, 0]),
|
||||
'always_increment_requested': ([
|
||||
StatsRow('email', 'delivered', 1),
|
||||
StatsRow('email', 'failed', 1)
|
||||
], [2, 1, 1], [0, 0, 0], [0, 0, 0]),
|
||||
], [2, 1, 1], [0, 0, 0]),
|
||||
'dont_mix_template_types': ([
|
||||
StatsRow('email', 'delivered', 1),
|
||||
StatsRow('sms', 'delivered', 1),
|
||||
StatsRow('letter', 'delivered', 1)
|
||||
], [1, 1, 0], [1, 1, 0], [1, 1, 0]),
|
||||
], [1, 1, 0], [1, 1, 0]),
|
||||
'convert_fail_statuses_to_failed': ([
|
||||
StatsRow('email', 'failed', 1),
|
||||
StatsRow('email', 'technical-failure', 1),
|
||||
StatsRow('email', 'temporary-failure', 1),
|
||||
StatsRow('email', 'permanent-failure', 1),
|
||||
StatsRow('letter', 'validation-failed', 1),
|
||||
StatsRow('letter', 'virus-scan-failed', 1),
|
||||
StatsRow('letter', 'permanent-failure', 1),
|
||||
StatsRow('letter', 'cancelled', 1),
|
||||
], [4, 0, 4], [0, 0, 0], [3, 0, 3]),
|
||||
], [4, 0, 4], [0, 0, 0]),
|
||||
'convert_sent_to_delivered': ([
|
||||
StatsRow('sms', 'sending', 1),
|
||||
StatsRow('sms', 'delivered', 1),
|
||||
StatsRow('sms', 'sent', 1),
|
||||
], [0, 0, 0], [3, 2, 0], [0, 0, 0]),
|
||||
], [0, 0, 0], [3, 2, 0]),
|
||||
'handles_none_rows': ([
|
||||
StatsRow('sms', 'sending', 1),
|
||||
StatsRow(None, None, None)
|
||||
], [0, 0, 0], [1, 0, 0], [0, 0, 0])
|
||||
], [0, 0, 0], [1, 0, 0])
|
||||
})
|
||||
def test_format_statistics(stats, email_counts, sms_counts, letter_counts):
|
||||
def test_format_statistics(stats, email_counts, sms_counts):
|
||||
|
||||
ret = format_statistics(stats)
|
||||
|
||||
@@ -66,18 +61,11 @@ def test_format_statistics(stats, email_counts, sms_counts, letter_counts):
|
||||
in zip(['requested', 'delivered', 'failed'], sms_counts)
|
||||
}
|
||||
|
||||
assert ret['letter'] == {
|
||||
status: count
|
||||
for status, count
|
||||
in zip(['requested', 'delivered', 'failed'], letter_counts)
|
||||
}
|
||||
|
||||
|
||||
def test_create_zeroed_stats_dicts():
|
||||
assert create_zeroed_stats_dicts() == {
|
||||
'sms': {'requested': 0, 'delivered': 0, 'failed': 0},
|
||||
'email': {'requested': 0, 'delivered': 0, 'failed': 0},
|
||||
'letter': {'requested': 0, 'delivered': 0, 'failed': 0},
|
||||
}
|
||||
|
||||
|
||||
@@ -95,12 +83,6 @@ def test_create_stats_dict():
|
||||
'permanent-failure': 0,
|
||||
'temporary-failure': 0,
|
||||
'virus-scan-failed': 0}},
|
||||
'letter': {'total': 0,
|
||||
'test-key': 0,
|
||||
'failures': {'technical-failure': 0,
|
||||
'permanent-failure': 0,
|
||||
'temporary-failure': 0,
|
||||
'virus-scan-failed': 0}}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +90,6 @@ def test_format_admin_stats_only_includes_test_key_notifications_in_test_key_sec
|
||||
rows = [
|
||||
NewStatsRow('email', 'technical-failure', 'test', 3),
|
||||
NewStatsRow('sms', 'permanent-failure', 'test', 4),
|
||||
NewStatsRow('letter', 'virus-scan-failed', 'test', 5),
|
||||
]
|
||||
stats_dict = format_admin_stats(rows)
|
||||
|
||||
@@ -120,10 +101,6 @@ def test_format_admin_stats_only_includes_test_key_notifications_in_test_key_sec
|
||||
assert stats_dict['sms']['failures']['permanent-failure'] == 0
|
||||
assert stats_dict['sms']['test-key'] == 4
|
||||
|
||||
assert stats_dict['letter']['total'] == 0
|
||||
assert stats_dict['letter']['failures']['virus-scan-failed'] == 0
|
||||
assert stats_dict['letter']['test-key'] == 5
|
||||
|
||||
|
||||
def test_format_admin_stats_counts_non_test_key_notifications_correctly():
|
||||
rows = [
|
||||
@@ -131,7 +108,6 @@ def test_format_admin_stats_counts_non_test_key_notifications_correctly():
|
||||
NewStatsRow('email', 'created', 'team', 3),
|
||||
NewStatsRow('sms', 'temporary-failure', 'normal', 6),
|
||||
NewStatsRow('sms', 'sent', 'normal', 2),
|
||||
NewStatsRow('letter', 'pending-virus-check', 'normal', 1),
|
||||
]
|
||||
stats_dict = format_admin_stats(rows)
|
||||
|
||||
@@ -141,8 +117,6 @@ def test_format_admin_stats_counts_non_test_key_notifications_correctly():
|
||||
assert stats_dict['sms']['total'] == 8
|
||||
assert stats_dict['sms']['failures']['permanent-failure'] == 0
|
||||
|
||||
assert stats_dict['letter']['total'] == 1
|
||||
|
||||
|
||||
def _stats(requested, delivered, failed):
|
||||
return {'requested': requested, 'delivered': delivered, 'failed': failed}
|
||||
@@ -180,7 +154,7 @@ def test_create_empty_monthly_notification_status_stats_dict(year, expected_year
|
||||
output = create_empty_monthly_notification_status_stats_dict(year)
|
||||
assert sorted(output.keys()) == expected_years
|
||||
for v in output.values():
|
||||
assert v == {'sms': {}, 'email': {}, 'letter': {}}
|
||||
assert v == {'sms': {}, 'email': {}}
|
||||
|
||||
|
||||
@freeze_time('2018-06-01 04:59:59')
|
||||
@@ -208,7 +182,7 @@ def test_add_monthly_notification_status_stats():
|
||||
add_monthly_notification_status_stats(data, rows)
|
||||
|
||||
assert data == {
|
||||
'2018-04': {'sms': {'sending': 1, 'delivered': 2}, 'email': {'sending': 4}, 'letter': {}},
|
||||
'2018-05': {'sms': {'sending': 24}, 'email': {'sending': 32}, 'letter': {}},
|
||||
'2018-06': {'sms': {}, 'email': {}, 'letter': {}},
|
||||
'2018-04': {'sms': {'sending': 1, 'delivered': 2}, 'email': {'sending': 4}},
|
||||
'2018-05': {'sms': {'sending': 24}, 'email': {'sending': 32}},
|
||||
'2018-06': {'sms': {}, 'email': {}},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user