mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Include test key data by default on platform admin
This is the existing behaviour. It’s broken by this issue in WTForms 2.2.1: https://github.com/wtforms/wtforms/issues/401 This commit hand-crafts the default value, because WTForms is ignoring the `default` argument on the form object attribute. Not really sure how this ever worked 🤔
This commit is contained in:
@@ -138,6 +138,14 @@ def make_columns(global_stats, complaints_number):
|
|||||||
@user_is_platform_admin
|
@user_is_platform_admin
|
||||||
def platform_admin_services():
|
def platform_admin_services():
|
||||||
form = DateFilterForm(request.args)
|
form = DateFilterForm(request.args)
|
||||||
|
if all((
|
||||||
|
request.args.get('include_from_test_key') is None,
|
||||||
|
request.args.get('start_date') is None,
|
||||||
|
request.args.get('end_date') is None,
|
||||||
|
)):
|
||||||
|
# Default to True if the user hasn’t done any filtering,
|
||||||
|
# otherwise respect their choice
|
||||||
|
form.include_from_test_key.data = True
|
||||||
api_args = {'detailed': True,
|
api_args = {'detailed': True,
|
||||||
'only_active': False, # specifically DO get inactive services
|
'only_active': False, # specifically DO get inactive services
|
||||||
'include_from_test_key': form.include_from_test_key.data,
|
'include_from_test_key': form.include_from_test_key.data,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
from functools import partial
|
||||||
from unittest.mock import ANY
|
from unittest.mock import ANY
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -114,12 +115,13 @@ def test_should_render_platform_admin_page(
|
|||||||
'main.live_services',
|
'main.live_services',
|
||||||
'main.trial_services',
|
'main.trial_services',
|
||||||
])
|
])
|
||||||
@pytest.mark.parametrize('include_from_test_key, inc', [
|
@pytest.mark.parametrize('partial_url_for, inc', [
|
||||||
("Y", True),
|
(partial(url_for), True),
|
||||||
("N", False)
|
(partial(url_for, include_from_test_key='y', start_date='', end_date=''), True),
|
||||||
|
(partial(url_for, start_date='', end_date=''), False),
|
||||||
])
|
])
|
||||||
def test_live_trial_services_toggle_including_from_test_key(
|
def test_live_trial_services_toggle_including_from_test_key(
|
||||||
include_from_test_key,
|
partial_url_for,
|
||||||
client,
|
client,
|
||||||
platform_admin_user,
|
platform_admin_user,
|
||||||
mocker,
|
mocker,
|
||||||
@@ -129,12 +131,14 @@ def test_live_trial_services_toggle_including_from_test_key(
|
|||||||
):
|
):
|
||||||
mock_get_user(mocker, user=platform_admin_user)
|
mock_get_user(mocker, user=platform_admin_user)
|
||||||
client.login(platform_admin_user)
|
client.login(platform_admin_user)
|
||||||
response = client.get(url_for(endpoint, include_from_test_key=include_from_test_key))
|
response = client.get(partial_url_for(endpoint))
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
mock_get_detailed_services.assert_called_once_with({'detailed': True,
|
mock_get_detailed_services.assert_called_once_with({
|
||||||
'only_active': False,
|
'detailed': True,
|
||||||
'include_from_test_key': inc})
|
'only_active': False,
|
||||||
|
'include_from_test_key': inc,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('endpoint', [
|
@pytest.mark.parametrize('endpoint', [
|
||||||
|
|||||||
Reference in New Issue
Block a user