Exemple #1
0
def get_total_sent_notifications_for_day(day):
    email_count = get_total_sent_notifications_for_day_and_type(day, 'email')
    sms_count = get_total_sent_notifications_for_day_and_type(day, 'sms')
    letter_count = get_total_sent_notifications_for_day_and_type(day, 'letter')

    return {
        "email": email_count,
        "sms": sms_count,
        "letter": letter_count,
    }
Exemple #2
0
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(
        utc_date=date - timedelta(days=1),
        notification_type=sample_template.template_type,
        service=sample_template.service,
        template=sample_template,
        count=1)
    create_ft_notification_status(
        utc_date=date,
        notification_type=sample_template.template_type,
        service=sample_template.service,
        template=sample_template,
        count=2)
    create_ft_notification_status(
        utc_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_right_notification_type(
        notification_type, count, sample_template, sample_email_template, sample_letter_template
):
    create_ft_notification_status(utc_date="2019-03-27", service=sample_template.service, template=sample_template,
                                  count=3)
    create_ft_notification_status(utc_date="2019-03-27", service=sample_email_template.service,
                                  template=sample_email_template, count=5)
    create_ft_notification_status(utc_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
Exemple #4
0
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