From 647c7a91d5b232ab2598d01c46bd643f9fb90c74 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 26 May 2023 14:52:33 -0700 Subject: [PATCH] more tests --- .../views/accounts/test_choose_accounts.py | 7 ++++-- .../test_service_setting_permissions.py | 24 +++++++++++++++---- .../service_settings/test_service_settings.py | 8 ++++++- tests/app/main/views/test_manage_users.py | 9 ++++++- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index e789f7f5e..da12a9e8c 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -267,7 +267,7 @@ def test_choose_account_should_not_show_back_to_service_link_if_not_signed_in( @pytest.mark.parametrize('active', ( False, - pytest.param(True, marks=pytest.mark.xfail(raises=AssertionError)), + pytest.param(True), )) def test_choose_account_should_not_show_back_to_service_link_if_service_archived( client_request, @@ -283,7 +283,10 @@ def test_choose_account_should_not_show_back_to_service_link_if_service_archived page = client_request.get('main.choose_account') assert normalize_spaces(page.select_one('h1').text) == 'Choose service' - assert page.select_one('.navigation-service a') is None + if active: + assert page.select_one('.navigation-service a') is not None + else: + assert page.select_one('.navigation-service a') is None def test_should_not_show_back_to_service_if_user_doesnt_belong_to_service( diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index 1b3502674..276dd973b 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -122,10 +122,6 @@ def test_service_setting_toggles_show( ({'active': True}, '.history', 2, 'Service history'), ({'active': False}, '.resume_service', 0, 'Resume service'), ({'active': False}, '.history', 1, 'Service history'), - pytest.param( - {'active': False}, '.archive_service', 2, 'Resume service', - marks=pytest.mark.xfail(raises=IndexError) - ) ]) def test_service_setting_link_toggles( get_service_settings_page, @@ -143,6 +139,26 @@ def test_service_setting_link_toggles( assert link['href'] == link_url +@pytest.mark.parametrize('service_fields, endpoint, index, text', [ + pytest.param( + {'active': False}, '.archive_service', 2, 'Resume service', + ) +]) +def test_service_setting_link_toggles_index_error( + get_service_settings_page, + service_one, + service_fields, + endpoint, + index, + text, +): + with pytest.raises(expected_exception=IndexError): + url_for(endpoint, service_id=service_one['id']) + service_one.update(service_fields) + page = get_service_settings_page() + page.select('.page-footer-link a')[index] + + @pytest.mark.parametrize('permissions,permissions_text,visible', [ ('sms', 'inbound SMS', True), ('inbound_sms', 'inbound SMS', False), # no sms parent permission diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 9b2c57e2c..a9b5effb3 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -3452,7 +3452,7 @@ def test_suspend_service_after_confirm_error( @pytest.mark.parametrize('user', ( create_platform_admin_user(), - pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), + pytest.param(create_active_user_with_permissions()), )) def test_suspend_service_prompts_user( client_request, @@ -3466,6 +3466,12 @@ def test_suspend_service_prompts_user( mock_api = mocker.patch('app.service_api_client.post') client_request.login(user) + + if user['email_address'] != 'platform@admin.gsa.gov': + with pytest.raises(expected_exception=AssertionError): + client_request.get('main.suspend_service', service_id=service_one['id']) + return + page = client_request.get('main.suspend_service', service_id=service_one['id']) assert 'This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?' in \ diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 0987e85e5..8ade6f3c9 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -191,7 +191,7 @@ def test_should_show_change_details_link( @pytest.mark.parametrize('number_of_users', ( - pytest.param(7, marks=pytest.mark.xfail), + pytest.param(7), pytest.param(8), )) def test_should_show_live_search_if_more_than_7_users( @@ -213,6 +213,13 @@ def test_should_show_live_search_if_more_than_7_users( page = client_request.get('main.manage_users', service_id=SERVICE_ONE_ID) + if number_of_users == 7: + with pytest.raises(expected_exception=TypeError): + assert page.select_one('div[data-module=live-search]')['data-targets'] == ( + ".user-list-item" + ) + return + assert page.select_one('div[data-module=live-search]')['data-targets'] == ( ".user-list-item" )