mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 17:24:23 -04:00
more test fixes & letter trimming
This commit is contained in:
@@ -922,96 +922,6 @@ def test_should_show_image_of_precompiled_letter_notification(
|
||||
assert mock_pdf_page_count.called_once()
|
||||
|
||||
|
||||
@freeze_time('2016-01-01 15:00')
|
||||
def test_show_cancel_letter_confirmation(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
):
|
||||
notification = create_notification(template_type='letter', notification_status='created')
|
||||
mocker.patch('app.notification_api_client.get_notification', return_value=notification)
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.get_page_count_for_letter',
|
||||
return_value=1
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.cancel_letter',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
|
||||
flash_message = normalize_spaces(page.find('div', class_='banner-dangerous').text)
|
||||
|
||||
assert 'Are you sure you want to cancel sending this letter?' in flash_message
|
||||
|
||||
|
||||
@freeze_time('2016-01-01 15:00')
|
||||
def test_cancelling_a_letter_calls_the_api(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
):
|
||||
notification = create_notification(template_type='letter', notification_status='created')
|
||||
mocker.patch('app.notification_api_client.get_notification', return_value=notification)
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.get_page_count_for_letter',
|
||||
return_value=1
|
||||
)
|
||||
cancel_endpoint = mocker.patch(
|
||||
'app.main.views.notifications.notification_api_client.update_notification_to_cancelled'
|
||||
)
|
||||
|
||||
client_request.post(
|
||||
'main.cancel_letter',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
_follow_redirects=True,
|
||||
_expected_redirect=None,
|
||||
)
|
||||
|
||||
assert cancel_endpoint.called
|
||||
|
||||
|
||||
@freeze_time('2016-01-01 15:00')
|
||||
@pytest.mark.parametrize('error_message', [
|
||||
"It’s too late to cancel this letter. Printing started on 1 January at 5.30pm",
|
||||
"This letter has already been cancelled",
|
||||
pytest.param("other message", marks=pytest.mark.xfail())
|
||||
])
|
||||
def test_cancel_letter_catches_errors_from_API(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
error_message
|
||||
):
|
||||
notification = create_notification(template_type='letter', notification_status='created')
|
||||
mocker.patch('app.notification_api_client.get_notification', return_value=notification)
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.get_page_count_for_letter',
|
||||
return_value=1
|
||||
)
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.notification_api_client.update_notification_to_cancelled',
|
||||
side_effect=HTTPError(response=Mock(
|
||||
status_code=400,
|
||||
json=Mock(
|
||||
return_value={'message': error_message}
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
page = client_request.post(
|
||||
'main.cancel_letter',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
assert page.find('h1').text.strip() == "Letter"
|
||||
assert page.select_one('div.banner-dangerous').text.strip() == error_message
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_type', ['sms', 'email'])
|
||||
def test_should_show_reply_to_from_notification(
|
||||
mocker,
|
||||
|
||||
Reference in New Issue
Block a user