mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-04 08:01:34 -04:00
Add option to exclude test key stats on platform admin page
This page currently includes all notifications for all services, including those sent using a test key. Stats on all other pages exclude test key usage, though, which can lead to confusion for admins comparing numbers between pages. Adding the option to toggle between including and excluding test key usage on the platform admin page gives context for this difference, and allows admins to see live usage of the platform as well as load associated with test key usage.
This commit is contained in:
@@ -87,6 +87,43 @@ def test_should_render_platform_admin_page(
|
||||
mock_get_detailed_services.assert_called_once_with({'detailed': True})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('include_from_test_key, expected_text, unexpected_text, api_args', [
|
||||
(True, 'Including test key', 'Excluding test key', {'detailed': True}),
|
||||
(False, 'Excluding test key', 'Including test key', {'detailed': True, 'include_from_test_key': False})
|
||||
])
|
||||
def test_platform_admin_toggle_including_from_test_key(
|
||||
include_from_test_key,
|
||||
expected_text,
|
||||
unexpected_text,
|
||||
api_args,
|
||||
app_,
|
||||
platform_admin_user,
|
||||
mocker,
|
||||
mock_get_detailed_services
|
||||
):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
mock_get_user(mocker, user=platform_admin_user)
|
||||
client.login(platform_admin_user)
|
||||
response = client.get(url_for('main.platform_admin', include_from_test_key=str(include_from_test_key)))
|
||||
|
||||
assert response.status_code == 200
|
||||
resp_data = response.get_data(as_text=True)
|
||||
assert expected_text in resp_data
|
||||
assert unexpected_text not in resp_data
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
change_link = page.find('a', text='change')
|
||||
assert change_link['href']
|
||||
query_param = 'include_from_test_key=False'
|
||||
if include_from_test_key:
|
||||
assert query_param in change_link['href']
|
||||
else:
|
||||
assert query_param not in change_link['href']
|
||||
|
||||
mock_get_detailed_services.assert_called_once_with(api_args)
|
||||
|
||||
|
||||
def test_create_global_stats_sets_failure_rates(fake_uuid):
|
||||
services = [
|
||||
service_json(fake_uuid, 'a', []),
|
||||
|
||||
Reference in New Issue
Block a user