mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 02:23:32 -04:00
Get and use sender_id from S3 metadata
The `save_email` and `save_sms` jobs were updated previously to take an optional `sender_id` and to use this if it was available. This commit now gets the `sender_id` from the S3 metadata if it exists and passes it through the the tasks which save the job notifications. This means SMS and emails sent through jobs can use a specified `sender_id` instead of the default.
This commit is contained in:
@@ -98,6 +98,7 @@ def test_create_unscheduled_job(client, sample_template, mocker, fake_uuid):
|
||||
|
||||
app.celery.tasks.process_job.apply_async.assert_called_once_with(
|
||||
([str(fake_uuid)]),
|
||||
{'sender_id': None},
|
||||
queue="job-tasks"
|
||||
)
|
||||
|
||||
@@ -113,6 +114,36 @@ def test_create_unscheduled_job(client, sample_template, mocker, fake_uuid):
|
||||
assert resp_json['data']['notification_count'] == 1
|
||||
|
||||
|
||||
def test_create_unscheduled_job_with_sender_id_in_metadata(client, sample_template, mocker, fake_uuid):
|
||||
mocker.patch('app.celery.tasks.process_job.apply_async')
|
||||
mocker.patch('app.job.rest.get_job_metadata_from_s3', return_value={
|
||||
'template_id': str(sample_template.id),
|
||||
'original_file_name': 'thisisatest.csv',
|
||||
'notification_count': '1',
|
||||
'valid': 'True',
|
||||
'sender_id': fake_uuid
|
||||
})
|
||||
data = {
|
||||
'id': fake_uuid,
|
||||
'created_by': str(sample_template.created_by.id),
|
||||
}
|
||||
path = '/service/{}/job'.format(sample_template.service.id)
|
||||
auth_header = create_authorization_header()
|
||||
headers = [('Content-Type', 'application/json'), auth_header]
|
||||
|
||||
response = client.post(
|
||||
path,
|
||||
data=json.dumps(data),
|
||||
headers=headers)
|
||||
assert response.status_code == 201
|
||||
|
||||
app.celery.tasks.process_job.apply_async.assert_called_once_with(
|
||||
([str(fake_uuid)]),
|
||||
{'sender_id': fake_uuid},
|
||||
queue="job-tasks"
|
||||
)
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 12:00:00.000000")
|
||||
def test_create_scheduled_job(client, sample_template, mocker, fake_uuid):
|
||||
scheduled_date = (datetime.utcnow() + timedelta(hours=95, minutes=59)).isoformat()
|
||||
|
||||
Reference in New Issue
Block a user