mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Show separate error for when user tries to cancel letter
that is already cancelled vs when it is too late to cancel letter vs when we don't know what's the cause of failure. This is so we could show useful error messages to the users and also for better debugging.
This commit is contained in:
@@ -3445,6 +3445,7 @@ def test_cancel_notification_for_service_raises_invalid_request_when_letter_is_i
|
||||
notification_status,
|
||||
):
|
||||
sample_letter_notification.status = notification_status
|
||||
sample_letter_notification.created_at = datetime.now()
|
||||
|
||||
response = admin_request.post(
|
||||
'service.cancel_notification_for_service',
|
||||
@@ -3452,7 +3453,13 @@ def test_cancel_notification_for_service_raises_invalid_request_when_letter_is_i
|
||||
notification_id=sample_letter_notification.id,
|
||||
_expected_status=400
|
||||
)
|
||||
assert response['message'] == 'It’s too late to cancel this letter. Printing started today at 5.30pm'
|
||||
if notification_status == 'cancelled':
|
||||
assert response['message'] == 'This letter has already been cancelled.'
|
||||
else:
|
||||
assert response['message'] == (
|
||||
f"We could not cancel this letter. "
|
||||
f"Letter status: {notification_status}, created_at: 2018-07-07 12:00:00"
|
||||
)
|
||||
assert response['result'] == 'error'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user