Add more properties of job to job message.

This commit is contained in:
Adam Shimali
2016-02-04 12:34:53 +00:00
parent 18c5e2d37d
commit aa57730fc9
2 changed files with 12 additions and 2 deletions

View File

@@ -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'}})

View File

@@ -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):