From 0d2de75e846601ee14038412ac0a2fb33d9007a6 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 30 Jul 2018 15:19:46 +0100 Subject: [PATCH 1/2] Bump utils to 29.3.4 https://github.com/alphagov/notifications-utils/compare/29.3.2...bullet-for-bullet --- requirements-app.txt | 2 +- requirements.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements-app.txt b/requirements-app.txt index 6c13ac1b0..7c43d26b4 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -21,4 +21,4 @@ notifications-python-client==4.10.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@29.3.2#egg=notifications-utils==29.3.2 +git+https://github.com/alphagov/notifications-utils.git@29.3.4#egg=notifications-utils==29.3.4 diff --git a/requirements.txt b/requirements.txt index e1313c244..7782e5270 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,13 +23,13 @@ notifications-python-client==4.10.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@29.3.2#egg=notifications-utils==29.3.2 +git+https://github.com/alphagov/notifications-utils.git@29.3.4#egg=notifications-utils==29.3.4 ## The following requirements were added by pip freeze: -awscli==1.15.55 +awscli==1.15.70 bleach==2.1.3 boto3==1.6.16 -botocore==1.10.54 +botocore==1.10.69 certifi==2018.4.16 chardet==3.0.4 click==6.7 @@ -39,7 +39,7 @@ docutils==0.14 et-xmlfile==1.0.1 Flask-Redis==0.3.0 future==0.16.0 -greenlet==0.4.13 +greenlet==0.4.14 html5lib==1.0.1 idna==2.7 itsdangerous==0.24 @@ -54,7 +54,7 @@ monotonic==1.5 openpyxl==2.5.4 orderedset==2.0.1 phonenumbers==8.9.4 -pyasn1==0.4.3 +pyasn1==0.4.4 pyexcel-ezodf==0.3.4 PyJWT==1.6.4 PyPDF2==1.26.0 @@ -72,6 +72,6 @@ texttable==1.4.0 urllib3==1.23 webencodings==0.5.1 Werkzeug==0.14.1 -WTForms==2.1 +WTForms==2.2.1 xlrd==1.1.0 xlwt==1.3.0 From 55054b81b5a6db50f90f20c4eabebb87950dbaba Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Aug 2018 14:30:34 +0100 Subject: [PATCH 2/2] Include test key data by default on platform admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 🤔 --- app/main/views/platform_admin.py | 8 ++++++++ tests/app/main/views/test_platform_admin.py | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index c8d8dfb93..b921d87e5 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -138,6 +138,14 @@ def make_columns(global_stats, complaints_number): @user_is_platform_admin def platform_admin_services(): 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, 'only_active': False, # specifically DO get inactive services 'include_from_test_key': form.include_from_test_key.data, diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py index 280f104fe..d67702178 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -1,6 +1,7 @@ import datetime import re import uuid +from functools import partial from unittest.mock import ANY import pytest @@ -114,12 +115,13 @@ def test_should_render_platform_admin_page( 'main.live_services', 'main.trial_services', ]) -@pytest.mark.parametrize('include_from_test_key, inc', [ - ("Y", True), - ("N", False) +@pytest.mark.parametrize('partial_url_for, inc', [ + (partial(url_for), True), + (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( - include_from_test_key, + partial_url_for, client, platform_admin_user, mocker, @@ -129,12 +131,14 @@ def test_live_trial_services_toggle_including_from_test_key( ): mock_get_user(mocker, user=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 - mock_get_detailed_services.assert_called_once_with({'detailed': True, - 'only_active': False, - 'include_from_test_key': inc}) + mock_get_detailed_services.assert_called_once_with({ + 'detailed': True, + 'only_active': False, + 'include_from_test_key': inc, + }) @pytest.mark.parametrize('endpoint', [