add tests for redact_template rest

This commit is contained in:
Leo Hemsted
2017-06-28 16:49:43 +01:00
parent bd71ee9d02
commit 8ad10261ec
3 changed files with 97 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ from app.models import (
ApiKey,
Template,
TemplateHistory,
TemplateRedacted,
Job,
NotificationHistory,
Notification,
@@ -218,6 +219,7 @@ def delete_service_and_all_associated_db_objects(service):
_delete_commit(Job.query.filter_by(service=service))
_delete_commit(NotificationHistory.query.filter_by(service=service))
_delete_commit(Notification.query.filter_by(service=service))
_delete_commit(TemplateRedacted.query.filter_by(service=service))
_delete_commit(Template.query.filter_by(service=service))
_delete_commit(TemplateHistory.query.filter_by(service_id=service.id))
_delete_commit(ServicePermission.query.filter_by(service_id=service.id))

View File

@@ -61,8 +61,10 @@ def update_template(service_id, template_id):
# if redacting, don't update anything else
if data.get('redact_personalisation') is True and 'updated_by_id' in data:
# we also don't need to check what was passed in redact_personalisation - its presence in the dict is enough.
dao_redact_template(fetched_template, data['updated_by_id'])
return '', 200
# also, only
if not fetched_template.redact_personalisation:
dao_redact_template(fetched_template, data['updated_by_id'])
return 'null', 200
current_data = dict(template_schema.dump(fetched_template).data.items())
updated_template = dict(template_schema.dump(fetched_template).data.items())