mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-26 17:23:50 -04:00
In this PR we remove trigger-letter-pdfs-for-day scheduled task and just call collate_letter_pdfs_for_day instead.
There was a datetime bug in the query which resulted in files not being sent to the postal provider. The trigger-letter-pdfs-for-day task is no longer needed, so rather than fix the query just call collate_letter_pdfs_for_day directly. Less code is always better. Deployment considerations: I realized this is strictly not backwards compatible if the scheduled job is in progress and a task is on the queue that no longer exists. This is ok since we will deploy this well before 17:50.
This commit is contained in:
@@ -10,7 +10,6 @@ from app.dao.notifications_dao import (
|
||||
dao_create_notification,
|
||||
dao_created_scheduled_notification,
|
||||
dao_delete_notifications_and_history_by_id,
|
||||
dao_get_count_of_letters_to_process_for_date,
|
||||
dao_get_last_notification_added_for_job_id,
|
||||
dao_get_last_template_usage,
|
||||
dao_get_notifications_by_to_field,
|
||||
@@ -1760,82 +1759,6 @@ def test_dao_get_notification_history_by_reference_with_no_matches_raises_error(
|
||||
dao_get_notification_history_by_reference('REF1')
|
||||
|
||||
|
||||
@freeze_time("2017-12-18 17:50")
|
||||
def test_dao_get_count_of_letters_to_process_for_today(sample_letter_template):
|
||||
# expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-17 17:30:00')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:59')
|
||||
|
||||
# not expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-17 17:29:59')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:30:00')
|
||||
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date()
|
||||
|
||||
assert count_for_date == 2
|
||||
|
||||
|
||||
@freeze_time("2017-12-18 17:50")
|
||||
def test_dao_get_count_of_letters_to_process_for_date_in_past(sample_letter_template):
|
||||
# expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-15 17:29:59')
|
||||
|
||||
# not expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-15 17:30:00')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:00')
|
||||
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date(date(2017, 12, 15))
|
||||
|
||||
assert count_for_date == 1
|
||||
|
||||
|
||||
@freeze_time("2017-12-18 17:50")
|
||||
def test_dao_get_count_of_letters_to_process_for_date_in_future_does_not_raise_error(sample_letter_template):
|
||||
# not expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:30:00')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-19 17:29:59')
|
||||
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date(date(2017, 12, 20))
|
||||
|
||||
assert count_for_date == 0
|
||||
|
||||
|
||||
def test_dao_get_count_of_letters_to_process_for_today_without_notis_does_not_raise_error(sample_letter_template):
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date()
|
||||
|
||||
assert count_for_date == 0
|
||||
|
||||
|
||||
@freeze_time("2017-12-18 17:50")
|
||||
def test_dao_get_count_of_letters_to_process_for_date_ignores_research_mode_services(sample_letter_template):
|
||||
research_service = create_service(service_name='research service', research_mode=True)
|
||||
research_template = create_template(research_service, template_type='letter')
|
||||
|
||||
# not expected
|
||||
create_notification(template=research_template, created_at='2017-12-18 17:29:00')
|
||||
|
||||
# expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:10')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:20')
|
||||
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date()
|
||||
assert count_for_date == 2
|
||||
|
||||
|
||||
@freeze_time("2017-12-18 17:50")
|
||||
def test_dao_get_count_of_letters_to_process_for_date_ignores_test_keys(sample_letter_template):
|
||||
# not expected
|
||||
create_notification(template=sample_letter_template, key_type=KEY_TYPE_TEST, created_at='2017-12-18 17:29:00')
|
||||
|
||||
# expected
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:10')
|
||||
create_notification(template=sample_letter_template, created_at='2017-12-18 17:29:20')
|
||||
|
||||
count_for_date = dao_get_count_of_letters_to_process_for_date()
|
||||
|
||||
assert count_for_date == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("notification_type",
|
||||
["letter", "email", "sms"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user