mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Use the template version at the time the notification is created or at the time the job is created.
Update notifications/sms|email endpoint to send the template version to the queue. Update the process_job celery talk to send the template version to the queue. When the send_sms|send_email task runs it will get the template by id and version. Created a data migration script to add the template_vesion column for jobs and notifications. The existing jobs and notifications are given the template_version of the current template. There is a chance this is the wrong template version, but deemed okay since the application is not live. Create unit test for the dao_get_template_versions method. Rename /template/<id>/version to /template/<id>/versions which returns all versions for that template id and service id.
This commit is contained in:
@@ -460,3 +460,27 @@ def test_update_400_for_over_limit_content(notify_api, sample_user, sample_templ
|
||||
assert (
|
||||
'Content has a character count greater than the limit of {}'
|
||||
).format(limit) in json_resp['message']['content']
|
||||
|
||||
|
||||
def test_should_return_all_template_versions_for_service_and_template_id(notify_api, sample_template):
|
||||
original_content = sample_template.content
|
||||
from app.dao.templates_dao import dao_update_template
|
||||
sample_template.content = original_content + '1'
|
||||
dao_update_template(sample_template)
|
||||
sample_template.content = original_content + '2'
|
||||
dao_update_template(sample_template)
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
auth_header = create_authorization_header()
|
||||
resp = client.get('/service/{}/template/{}/versions'.format(sample_template.service_id, sample_template.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert resp.status_code == 200
|
||||
resp_json = json.loads(resp.get_data(as_text=True))['data']
|
||||
assert len(resp_json) == 3
|
||||
for x in resp_json:
|
||||
if x['version'] == 1:
|
||||
assert x['content'] == original_content
|
||||
elif x['version'] == 2:
|
||||
assert x['content'] == original_content + '1'
|
||||
else:
|
||||
assert x['content'] == original_content + '2'
|
||||
|
||||
Reference in New Issue
Block a user