Return status code 304 when template is not updated.

Moved import
This commit is contained in:
Rebecca Law
2016-06-01 11:50:45 +01:00
parent 0a9cdbd75a
commit 05e72b07ae
2 changed files with 3 additions and 3 deletions

View File

@@ -64,7 +64,7 @@ def update_template(service_id, template_id):
update_template['content'] = _strip_html(update_template['content'])
# Check if there is a change to make.
if current_data == update_template:
return jsonify(data=update_template), 200
return jsonify(data=update_template), 304
update_dict, errors = template_schema.load(update_template)
if errors:

View File

@@ -3,6 +3,7 @@ import random
import string
from app.models import Template
from tests import create_authorization_header
from app.dao.templates_dao import dao_get_template_by_id
def test_should_create_a_new_sms_template_for_a_service(notify_api, sample_user, sample_service):
@@ -439,7 +440,6 @@ def test_update_does_not_create_new_version_when_there_is_no_change(notify_api,
resp = client.post('/service/{}/template/{}'.format(sample_template.service_id, sample_template.id),
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 200
from app.dao.templates_dao import dao_get_template_by_id
assert resp.status_code == 304
template = dao_get_template_by_id(sample_template.id)
assert template.version == 1