Return 400 for bad date argument

It’s more of a bad request, because the input is bad, rather than
something on our side being not found.
This commit is contained in:
Chris Hill-Scott
2020-05-13 08:56:54 +01:00
parent c61f7e70c2
commit cce153eee8
2 changed files with 2 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ def get_uploaded_letter_by_service_and_print_day(service_id, letter_print_date):
try: try:
letter_print_datetime = datetime.strptime(letter_print_date, '%Y-%m-%d') letter_print_datetime = datetime.strptime(letter_print_date, '%Y-%m-%d')
except ValueError: except ValueError:
abort(404) abort(400)
pagination = dao_get_uploaded_letters_by_print_date( pagination = dao_get_uploaded_letters_by_print_date(
service_id, service_id,
letter_print_date=letter_print_datetime, letter_print_date=letter_print_datetime,

View File

@@ -245,5 +245,5 @@ def test_get_uploaded_letters_by_print_date_404s_for_bad_date(
'upload.get_uploaded_letter_by_service_and_print_day', 'upload.get_uploaded_letter_by_service_and_print_day',
service_id=sample_service.id, service_id=sample_service.id,
letter_print_date='foo', letter_print_date='foo',
_expected_status=404, _expected_status=400,
) )