From 7fe56cf99297a2bef50345245e4457d03e269349 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Wed, 30 Nov 2016 17:05:39 +0000 Subject: [PATCH 1/3] Add request ID logging to the API. - adds a request ID if needed to use in all log events - respects request-ids passed in from calling clients --- app/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 6cca86bf5..8b22ec77d 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -6,7 +6,7 @@ from flask import request, url_for, g, jsonify from flask.ext.sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow from monotonic import monotonic -from notifications_utils import logging +from notifications_utils import logging, request_id from werkzeug.local import LocalProxy from app.celery.celery import NotifyCelery @@ -48,6 +48,7 @@ def create_app(app_name=None): application.config['NOTIFY_APP_NAME'] = app_name init_app(application) + request_id.init_app(application) db.init_app(application) ma.init_app(application) statsd_client.init_app(application) From d8625f9da4ac6ce8ead07af0e04e654f9397e53b Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Wed, 30 Nov 2016 17:22:03 +0000 Subject: [PATCH 2/3] Fixed tests that failed due to changes in utils brought in by latest version. - seems phonenumber/emailaddress from the CSV are now passed in as personalisation. - assume the renderer does the correct thing here. Will need to check with @quis --- tests/app/celery/test_tasks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index 0b9d255dc..2846fac7d 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -70,7 +70,7 @@ def test_should_process_sms_job(sample_job, mocker): assert encryption.encrypt.call_args[0][0]['to'] == '+441234123123' assert encryption.encrypt.call_args[0][0]['template'] == str(sample_job.template.id) assert encryption.encrypt.call_args[0][0]['template_version'] == sample_job.template.version - assert encryption.encrypt.call_args[0][0]['personalisation'] == {} + assert encryption.encrypt.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123123'} assert encryption.encrypt.call_args[0][0]['row_number'] == 0 tasks.send_sms.apply_async.assert_called_once_with( (str(sample_job.service_id), @@ -288,7 +288,7 @@ def test_should_process_email_job(sample_email_job, mocker): assert encryption.encrypt.call_args[0][0]['to'] == 'test@test.com' assert encryption.encrypt.call_args[0][0]['template'] == str(sample_email_job.template.id) assert encryption.encrypt.call_args[0][0]['template_version'] == sample_email_job.template.version - assert encryption.encrypt.call_args[0][0]['personalisation'] == {} + assert encryption.encrypt.call_args[0][0]['personalisation'] == {'emailaddress': 'test@test.com'} tasks.send_email.apply_async.assert_called_once_with( ( str(sample_email_job.service_id), @@ -320,7 +320,7 @@ def test_should_process_all_sms_job(sample_job, assert encryption.encrypt.call_args[0][0]['template'] == str(sample_job_with_placeholdered_template.template.id) assert encryption.encrypt.call_args[0][0][ 'template_version'] == sample_job_with_placeholdered_template.template.version # noqa - assert encryption.encrypt.call_args[0][0]['personalisation'] == {'name': 'chris'} + assert encryption.encrypt.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123120', 'name': 'chris'} tasks.send_sms.apply_async.call_count == 10 job = jobs_dao.dao_get_job_by_id(sample_job_with_placeholdered_template.id) assert job.job_status == 'finished' From 5ae21bf1d5dd9b9874c69ffb00fbe3baee9df876 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Thu, 1 Dec 2016 11:34:38 +0000 Subject: [PATCH 3/3] Bumped requirements version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c4c53b5d1..f79de9275 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,6 +22,6 @@ Flask-Redis==0.1.0 git+https://github.com/alphagov/notifications-python-client.git@3.0.0#egg=notifications-python-client==3.0.0 -git+https://github.com/alphagov/notifications-utils.git@9.2.1#egg=notifications-utils==9.2.1 +git+https://github.com/alphagov/notifications-utils.git@10.3.0#egg=notifications-utils==10.3.0 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3