mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 08:16:19 -04:00
Merge pull request #3418 from alphagov/letters-too-long
Mark letters as validation-failed if the templated letter is too long.
This commit is contained in:
@@ -1698,20 +1698,35 @@ def test_letters_to_be_printed_sort_by_service(notify_db_session):
|
||||
assert [x.id for x in results] == [x.id for x in letters_ordered_by_service_then_time]
|
||||
|
||||
|
||||
def test_letters_to_be_printed_does_not_include_letters_without_billable_units_set(
|
||||
notify_db_session, sample_letter_template):
|
||||
included_letter = create_notification(
|
||||
template=sample_letter_template, created_at=datetime(2020, 12, 1, 9, 30), billable_units=3)
|
||||
create_notification(
|
||||
template=sample_letter_template, created_at=datetime(2020, 12, 1, 9, 31), billable_units=0)
|
||||
|
||||
results = list(
|
||||
dao_get_letters_to_be_printed(print_run_deadline=datetime(2020, 12, 1, 17, 30), postage='second', query_limit=4)
|
||||
)
|
||||
assert len(results) == 1
|
||||
assert results[0].id == included_letter.id
|
||||
|
||||
|
||||
def test_dao_get_letters_and_sheets_volume_by_postage(notify_db_session):
|
||||
first_service = create_service(service_name='first service', service_id='3a5cea08-29fd-4bb9-b582-8dedd928b149')
|
||||
second_service = create_service(service_name='second service', service_id='642bf33b-54b5-45f2-8c13-942a46616704')
|
||||
first_template = create_template(service=first_service, template_type='letter', postage='second')
|
||||
second_template = create_template(service=second_service, template_type='letter', postage='second')
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 9, 30), postage='first'),
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 12, 30), postage='europe'),
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 13, 30), postage='rest-of-world'),
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 14, 30), billable_units=3),
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 15, 30)),
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 30), postage='first'),
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 31), postage='first'),
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 32)),
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 33)),
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 9, 30), postage='first')
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 12, 30), postage='europe')
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 13, 30), postage='rest-of-world')
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 14, 30), billable_units=3)
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 14, 30), billable_units=0)
|
||||
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 15, 30))
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 30), postage='first')
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 31), postage='first')
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 32))
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 33))
|
||||
create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 34))
|
||||
|
||||
results = dao_get_letters_and_sheets_volume_by_postage(print_run_deadline=datetime(2020, 12, 1, 17, 30))
|
||||
|
||||
Reference in New Issue
Block a user