From c532e57751e9878a86ee2637d8e30f438ceb6739 Mon Sep 17 00:00:00 2001 From: David McDonald Date: Thu, 4 Nov 2021 11:28:32 +0000 Subject: [PATCH] Dry up and standardise GET test for edit email reply to address This moves things out of the parametrization that didn't need to be in there and also makes the test match the test below, test_shows_delete_link_for_error_on_post_request_for_edit_email_reply_to_address, more closely. --- tests/app/main/views/test_service_settings.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 4b61d0dd6..6f90ff1eb 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -2881,23 +2881,20 @@ def test_add_edit_reply_to_email_address_goes_straight_to_update_if_address_not_ assert mock_update_reply_to_email_address.called is False -@pytest.mark.parametrize('reply_to_address, expected_link_text, partial_href', [ +@pytest.mark.parametrize('reply_to_address, default_choice_and_delete_link_expected', [ ( create_reply_to_email_address(is_default=False), - 'Delete', - partial(url_for, 'main.service_confirm_delete_email_reply_to', reply_to_email_id=sample_uuid()), + True, ), ( create_reply_to_email_address(is_default=True), - None, - None, + False, ), ]) def test_shows_delete_link_for_get_request_for_edit_email_reply_to_address( mocker, reply_to_address, - expected_link_text, - partial_href, + default_choice_and_delete_link_expected, fake_uuid, client_request, ): @@ -2915,10 +2912,16 @@ def test_shows_delete_link_for_get_request_for_edit_email_reply_to_address( service_id=SERVICE_ONE_ID, ) - if expected_link_text: + if default_choice_and_delete_link_expected: link = page.select_one('.page-footer a') - assert normalize_spaces(link.text) == expected_link_text - assert link['href'] == partial_href(service_id=SERVICE_ONE_ID) + assert normalize_spaces(link.text) == 'Delete' + assert link['href'] == url_for( + 'main.service_confirm_delete_email_reply_to', + service_id=SERVICE_ONE_ID, + reply_to_email_id=sample_uuid() + ) + assert not page.select_one('input#is_default').has_attr('checked') + else: assert not page.select('.page-footer a')