mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Get all versions for a template endpoint added.
This commit is contained in:
@@ -62,3 +62,30 @@ def test_404_missing_template_version(notify_api, sample_template):
|
||||
headers=[('Content-Type', 'application/json'), auth_header]
|
||||
)
|
||||
assert resp.status_code == 404
|
||||
|
||||
|
||||
def test_all_versions_of_template(notify_api, sample_template):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
old_content = sample_template.content
|
||||
newer_content = "Newer content"
|
||||
newest_content = "Newest content"
|
||||
sample_template.content = newer_content
|
||||
dao_update_template(sample_template)
|
||||
sample_template.content = newest_content
|
||||
dao_update_template(sample_template)
|
||||
auth_header = create_authorization_header()
|
||||
endpoint = url_for(
|
||||
'template.get_template_versions',
|
||||
service_id=sample_template.service.id,
|
||||
template_id=sample_template.id
|
||||
)
|
||||
resp = client.get(
|
||||
endpoint,
|
||||
headers=[('Content-Type', 'application/json'), auth_header]
|
||||
)
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert len(json_resp['data']) == 3
|
||||
assert json_resp['data'][0]['content'] == newest_content
|
||||
assert json_resp['data'][1]['content'] == newer_content
|
||||
assert json_resp['data'][2]['content'] == old_content
|
||||
|
||||
Reference in New Issue
Block a user