Revert "Purge notifications for configured days of retention"

This commit is contained in:
Rebecca Law
2018-08-03 14:35:36 +01:00
committed by GitHub
parent 691f24f94e
commit 019c6a4e3a
11 changed files with 148 additions and 337 deletions

View File

@@ -534,7 +534,7 @@ def test_fetch_stats_filters_on_service(sample_notification):
message_limit=1000)
dao_create_service(service_two, sample_notification.service.created_by)
stats = dao_fetch_stats_for_service(service_two.id, 7)
stats = dao_fetch_stats_for_service(service_two.id)
assert len(stats) == 0
@@ -546,7 +546,7 @@ def test_fetch_stats_ignores_historical_notification_data(sample_notification):
assert Notification.query.count() == 0
assert NotificationHistory.query.count() == 1
stats = dao_fetch_stats_for_service(service_id, 7)
stats = dao_fetch_stats_for_service(service_id)
assert len(stats) == 0
@@ -557,7 +557,7 @@ def test_fetch_stats_counts_correctly(notify_db, notify_db_session, sample_templ
create_notification(notify_db, notify_db_session, template=sample_email_template, status='technical-failure')
create_notification(notify_db, notify_db_session, template=sample_template, status='created')
stats = dao_fetch_stats_for_service(sample_template.service_id, 7)
stats = dao_fetch_stats_for_service(sample_template.service_id)
stats = sorted(stats, key=lambda x: (x.notification_type, x.status))
assert len(stats) == 3
@@ -591,7 +591,7 @@ def test_fetch_stats_counts_should_ignore_team_key(
create_notification(
notify_db, notify_db_session)
stats = dao_fetch_stats_for_service(sample_template.service_id, 7)
stats = dao_fetch_stats_for_service(sample_template.service_id)
assert len(stats) == 1
assert stats[0].notification_type == 'sms'
assert stats[0].status == 'created'
@@ -634,30 +634,7 @@ def test_fetch_stats_should_not_gather_notifications_older_than_7_days(sample_te
create_notification_db(sample_template,)
with freeze_time('Monday 16th July 2018 12:00'):
stats = dao_fetch_stats_for_service(sample_template.service_id, 7)
assert len(stats) == rows_returned
@pytest.mark.parametrize('created_at, rows_returned', [
('Saturday 7th July 2018 12:00', 0),
('Saturday 7th July 2018 22:59', 0),
('Sunday 8th July 2018 12:00', 1),
('Sunday 8th July 2018 22:59', 1),
('Sunday 8th July 2018 23:00', 1),
('Monday 9th July 2018 09:00', 1),
('Monday 9th July 2018 15:00', 1),
('Monday 16th July 2018 12:00', 1),
])
def test_fetch_stats_should_not_gather_notifications_older_than_the_days_given(
sample_template, created_at, rows_returned
):
# It's monday today. Things made last monday should still show
with freeze_time(created_at):
create_notification_db(sample_template,)
with freeze_time('Monday 16th July 2018 12:00'):
stats = dao_fetch_stats_for_service(sample_template.service_id, 8)
stats = dao_fetch_stats_for_service(sample_template.service_id)
assert len(stats) == rows_returned