mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Remove everything for the performance platform
We no longer will send them any stats so therefore don't need the code - the code to work out the nightly stats - the performance platform client - any configuration for the client - any nightly tasks that kick off the sending off the stats We will require a change in cronitor as we no longer will have this task run meaning we need to delete the cronitor check.
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.dao.notifications_dao import (
|
||||
dao_get_total_notifications_sent_per_day_for_performance_platform,
|
||||
)
|
||||
from app.models import KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST
|
||||
from tests.app.db import create_notification
|
||||
|
||||
BEGINNING_OF_DAY = date(2016, 10, 18)
|
||||
END_OF_DAY = date(2016, 10, 19)
|
||||
|
||||
|
||||
def test_get_total_notifications_filters_on_date_within_date_range(sample_template):
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 17, 23, 59, 59))
|
||||
create_notification(sample_template, created_at=BEGINNING_OF_DAY)
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 18, 23, 59, 59))
|
||||
create_notification(sample_template, created_at=END_OF_DAY)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 2
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_only_counts_api_notifications(sample_template, sample_job, sample_api_key):
|
||||
create_notification(sample_template, one_off=True)
|
||||
create_notification(sample_template, one_off=True)
|
||||
create_notification(sample_template, job=sample_job)
|
||||
create_notification(sample_template, job=sample_job)
|
||||
create_notification(sample_template, api_key=sample_api_key)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 1
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_ignores_test_keys(sample_template):
|
||||
# Creating multiple templates with normal and team keys but only 1 template
|
||||
# with a test key to test that the count ignores letters
|
||||
create_notification(sample_template, key_type=KEY_TYPE_NORMAL)
|
||||
create_notification(sample_template, key_type=KEY_TYPE_NORMAL)
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEAM)
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEAM)
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEST)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 4
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_ignores_letters(
|
||||
sample_template,
|
||||
sample_email_template,
|
||||
sample_letter_template
|
||||
):
|
||||
# Creating multiple sms and email templates but only 1 letter template to
|
||||
# test that the count ignores letters
|
||||
create_notification(sample_template)
|
||||
create_notification(sample_template)
|
||||
create_notification(sample_email_template)
|
||||
create_notification(sample_email_template)
|
||||
create_notification(sample_letter_template)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 4
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_counts_messages_within_10_seconds(sample_template):
|
||||
created_at = datetime.utcnow()
|
||||
|
||||
create_notification(sample_template, sent_at=created_at + timedelta(seconds=5))
|
||||
create_notification(sample_template, sent_at=created_at + timedelta(seconds=10))
|
||||
create_notification(sample_template, sent_at=created_at + timedelta(seconds=15))
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 3
|
||||
assert result.messages_within_10_secs == 2
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_counts_messages_that_have_not_sent(sample_template):
|
||||
create_notification(sample_template, status='created', sent_at=None)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 1
|
||||
assert result.messages_within_10_secs == 0
|
||||
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_returns_zero_if_no_data(notify_db_session):
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 0
|
||||
assert result.messages_within_10_secs == 0
|
||||
@@ -16,7 +16,6 @@ from app.dao.fact_notification_status_dao import (
|
||||
fetch_notification_statuses_for_job,
|
||||
fetch_stats_for_all_services_by_date_range,
|
||||
get_total_notifications_for_date_range,
|
||||
get_total_sent_notifications_for_day_and_type,
|
||||
update_fact_notification_status,
|
||||
)
|
||||
from app.models import (
|
||||
@@ -601,51 +600,6 @@ def test_fetch_monthly_template_usage_for_service_does_not_include_test_notifica
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("notification_type, count",
|
||||
[("sms", 3),
|
||||
("email", 5),
|
||||
("letter", 7)])
|
||||
def test_get_total_sent_notifications_for_day_and_type_returns_right_notification_type(
|
||||
notification_type, count, sample_template, sample_email_template, sample_letter_template
|
||||
):
|
||||
create_ft_notification_status(bst_date="2019-03-27", service=sample_template.service, template=sample_template,
|
||||
count=3)
|
||||
create_ft_notification_status(bst_date="2019-03-27", service=sample_email_template.service,
|
||||
template=sample_email_template, count=5)
|
||||
create_ft_notification_status(bst_date="2019-03-27", service=sample_letter_template.service,
|
||||
template=sample_letter_template, count=7)
|
||||
|
||||
result = get_total_sent_notifications_for_day_and_type(day='2019-03-27', notification_type=notification_type)
|
||||
|
||||
assert result == count
|
||||
|
||||
|
||||
@pytest.mark.parametrize("day",
|
||||
["2019-01-27", "2019-04-02"])
|
||||
def test_get_total_sent_notifications_for_day_and_type_returns_total_for_right_day(
|
||||
day, sample_template
|
||||
):
|
||||
date = datetime.strptime(day, "%Y-%m-%d")
|
||||
create_ft_notification_status(bst_date=date - timedelta(days=1), notification_type=sample_template.template_type,
|
||||
service=sample_template.service, template=sample_template, count=1)
|
||||
create_ft_notification_status(bst_date=date, notification_type=sample_template.template_type,
|
||||
service=sample_template.service, template=sample_template, count=2)
|
||||
create_ft_notification_status(bst_date=date + timedelta(days=1), notification_type=sample_template.template_type,
|
||||
service=sample_template.service, template=sample_template, count=3)
|
||||
|
||||
total = get_total_sent_notifications_for_day_and_type(day, sample_template.template_type)
|
||||
|
||||
assert total == 2
|
||||
|
||||
|
||||
def test_get_total_sent_notifications_for_day_and_type_returns_zero_when_no_counts(
|
||||
notify_db_session
|
||||
):
|
||||
total = get_total_sent_notifications_for_day_and_type("2019-03-27", "sms")
|
||||
|
||||
assert total == 0
|
||||
|
||||
|
||||
@freeze_time('2019-05-10 14:00')
|
||||
def test_fetch_monthly_notification_statuses_per_service(notify_db_session):
|
||||
service_one = create_service(service_name='service one', service_id=UUID('e4e34c4e-73c1-4802-811c-3dd273f21da4'))
|
||||
|
||||
Reference in New Issue
Block a user