def test_get_letter_notifications_still_sending_when_they_shouldnt_be_finds_no_letters_on_weekend(
        sample_letter_template):
    yesterday = datetime(2018, 1, 13, 13, 30)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=yesterday)

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 0
def test_get_letter_notifications_still_sending_when_they_shouldnt_finds_letters_older_than_offset(
        sample_letter_template):
    three_days_ago = datetime(2018, 1, 14, 13, 30)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=three_days_ago)

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 1
    assert expected_sent_date == date(2018, 1, 15)
def test_get_letter_notifications_still_sending_when_they_shouldnt_finds_no_letters_if_sent_a_day_ago(
        sample_letter_template):
    today = datetime.utcnow()
    one_day_ago = today - timedelta(days=1)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=one_day_ago)

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 0
def test_get_letter_notifications_still_sending_when_they_shouldnt_only_finds_letters_still_in_sending_status(
        sample_letter_template):
    two_days_ago = datetime(2018, 1, 15, 13, 30)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=two_days_ago)
    create_notification(template=sample_letter_template,
                        status='delivered',
                        sent_at=two_days_ago)
    create_notification(template=sample_letter_template,
                        status='failed',
                        sent_at=two_days_ago)

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 1
    assert expected_sent_date == date(2018, 1, 15)
Example #5
0
def test_get_letter_notifications_still_sending_when_they_shouldnt_finds_thursday_letters_when_run_on_monday(
        sample_letter_template):
    thursday = datetime(2018, 1, 11, 13, 30)
    yesterday = datetime(2018, 1, 14, 13, 30)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=thursday,
                        postage='second')
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=yesterday,
                        postage='second')

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 1
    assert expected_sent_date == date(2018, 1, 11)
Example #6
0
def test_get_letter_notifications_still_sending_when_they_shouldnt_finds_friday_letters_when_run_on_tuesday(
        sample_letter_template):
    friday = datetime(2018, 1, 12, 13, 30)
    yesterday = datetime(2018, 1, 14, 13, 30)
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=friday,
                        postage='first')
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=yesterday,
                        postage='first')
    # doesn't get reported because it's second class, and it's tuesday today
    create_notification(template=sample_letter_template,
                        status='sending',
                        sent_at=friday,
                        postage='second')

    count, expected_sent_date = get_letter_notifications_still_sending_when_they_shouldnt_be(
    )
    assert count == 1
    assert expected_sent_date == date(2018, 1, 12)