From aa57730fc9cfce4948fb6e2f622f2e7e6927b232 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Thu, 4 Feb 2016 12:34:53 +0000 Subject: [PATCH] Add more properties of job to job message. --- app/job/rest.py | 12 ++++++++++-- tests/app/job/test_job_rest.py | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/job/rest.py b/app/job/rest.py index 975b2eb9e..853408b10 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -61,7 +61,15 @@ def _enqueue_job(job): queue_name = current_app.config['NOTIFY_JOB_QUEUE'] queue = boto3.resource('sqs', region_name=aws_region).create_queue(QueueName=queue_name) - job_json = json.dumps({'job_id': str(job.id), 'service_id': str(job.service.id)}) + data = { + 'job_id': str(job.id), + 'service_id': str(job.service.id), + 'template_id': job.template_id, + 'bucket_name': job.bucket_name + } + job_json = json.dumps(data) queue.send_message(MessageBody=job_json, MessageAttributes={'job_id': {'StringValue': str(job.id), 'DataType': 'String'}, - 'service_id': {'StringValue': str(job.service.id), 'DataType': 'String'}}) + 'service_id': {'StringValue': str(job.service.id), 'DataType': 'String'}, + 'template_id': {'StringValue': str(job.template_id), 'DataType': 'Number'}, + 'bucket_name': {'StringValue': job.bucket_name, 'DataType': 'String'}}) diff --git a/tests/app/job/test_job_rest.py b/tests/app/job/test_job_rest.py index b8af8f7e9..e70b64120 100644 --- a/tests/app/job/test_job_rest.py +++ b/tests/app/job/test_job_rest.py @@ -121,6 +121,8 @@ def test_create_job(notify_api, notify_db, notify_db_session, sample_template): expected_message = json.loads(messages[0].body) assert expected_message['job_id'] == str(job_id) assert expected_message['service_id'] == str(service_id) + assert expected_message['template_id'] == template_id + assert expected_message['bucket_name'] == bucket_name def _setup_jobs(notify_db, notify_db_session, template, number_of_jobs=5):