From 30d0944ca1db330a44d55c111dcd417942a7ed09 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 9 Sep 2016 15:50:14 +0100 Subject: [PATCH 1/4] remove unused notification.html template --- app/templates/views/notification.html | 33 --------------------------- 1 file changed, 33 deletions(-) delete mode 100644 app/templates/views/notification.html diff --git a/app/templates/views/notification.html b/app/templates/views/notification.html deleted file mode 100644 index ca550b02c..000000000 --- a/app/templates/views/notification.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "withnav_template.html" %} -{% from "components/sms-message.html" import sms_message, message_status %} -{% from "components/banner.html" import banner %} -{% from "components/page-footer.html" import page_footer %} - -{% block page_title %} - Text message – GOV.UK Notify -{% endblock %} - -{% block maincolumn_content %} - - -

- Text message -

- -
-
- {{ sms_message(message.message, message.phone) }} -
-
- {{ banner( - "{} {}".format(message.status, delivered_at) - ) }} -
-
- - {{ page_footer( - secondary_link = url_for('.view_job', service_id=current_service.id, job_id=job_id), - secondary_link_text = 'View other messages in this job' - ) }} - -{% endblock %} From 816ba32b257a774feda22a4250f810c2544694f1 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 9 Sep 2016 15:50:55 +0100 Subject: [PATCH 2/4] add id field containg obj id to table if available useful for finding out a notification ID when investigating support issues --- app/templates/components/table.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index bf8893592..21a73f185 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -28,7 +28,7 @@ {% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %} {% for item in items %} - {% call row() %} + {% call row(item.id) %} {{ parent_caller(item, loop.index + 1) }} {% endcall %} {% endfor %} @@ -43,8 +43,8 @@ {%- endmacro %} -{% macro row() -%} - +{% macro row(id=None) -%} + {{ caller() }} {%- endmacro %} From c47ce9b26f2476043c52df6667b297b15644b4de Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 9 Sep 2016 16:29:30 +0100 Subject: [PATCH 3/4] bump test requirements to most recent --- requirements_for_test.txt | 12 ++++++------ setup.cfg | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements_for_test.txt b/requirements_for_test.txt index ac3893c5c..6fd918fec 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -1,11 +1,11 @@ -r requirements.txt pep8==1.7.0 -pytest==2.9.1 -pytest-mock==0.11.0 -pytest-cov==2.2.1 +pytest==3.0.2 +pytest-mock==1.2 +pytest-cov==2.3.1 pytest-xdist==1.14 coveralls==1.1 -moto==0.4.23 +moto==0.4.25 httpretty==0.8.14 -beautifulsoup4==4.4.1 -freezegun==0.3.6 +beautifulsoup4==4.5.1 +freezegun==0.3.7 diff --git a/setup.cfg b/setup.cfg index 5ba75b413..af94d5aee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,5 +2,5 @@ max-line-length = 120 exclude = ./migrations,./venv,./venv3,./node_modules,./bower_components -[pytest] +[tool:pytest] norecursedirs = node_modules bower_components From 62868bc0149bc00fbe81f96c14b0a5d913698c2a Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 9 Sep 2016 16:30:07 +0100 Subject: [PATCH 4/4] add test for id appearing in notification table use new pytest yield fixture --- tests/__init__.py | 1 + tests/app/main/views/test_jobs.py | 24 +++++++++++++++++++++++- tests/conftest.py | 6 ++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index a3cb0da0c..d91d80cd0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -225,6 +225,7 @@ def notification_json( data = { 'notifications': [{ + 'id': uuid.uuid4(), 'to': to, 'template': { 'id': template['id'], diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 547046c4a..4d9f7de52 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -1,4 +1,5 @@ import json +import uuid from urllib.parse import quote import pytest @@ -61,7 +62,6 @@ def test_should_show_page_for_one_job( status_argument, expected_api_call ): - file_name = mock_get_job(service_one['id'], fake_uuid)['data']['original_file_name'] with app_.test_request_context(), app_.test_client() as client: client.login(active_user_with_permissions, mocker, service_one) response = client.get(url_for( @@ -451,3 +451,25 @@ def test_get_status_filters_constructs_links(app_): link = ret[0][2] assert link == '/services/foo/notifications/sms?status={}'.format(quote('sending,delivered,failed')) + + +def test_html_contains_notification_id( + client, + service_one, + active_user_with_permissions, + mock_get_notifications, + mock_get_detailed_service, + mocker +): + client.login(active_user_with_permissions, mocker, service_one) + response = client.get(url_for( + 'main.view_notifications', + service_id=service_one['id'], + message_type='sms', + status='') + ) + assert response.status_code == 200 + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + notifications = page.tbody.find_all('tr') + for tr in notifications: + assert uuid.UUID(tr.attrs['id']) diff --git a/tests/conftest.py b/tests/conftest.py index c250abdf2..c884da70e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1202,3 +1202,9 @@ def mock_get_organisation(mocker): return mocker.patch( 'app.organisations_client.get_organisation', side_effect=_get_organisation ) + + +@pytest.fixture(scope='function') +def client(app_): + with app_.test_request_context(), app_.test_client() as client: + yield client