Get all versions for a template endpoint added.

This commit is contained in:
Nicholas Staples
2016-05-09 15:59:34 +01:00
parent f06aaa924e
commit b28474d74c
3 changed files with 45 additions and 3 deletions

View File

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