From 356083e8ac10713e43ee421da9a8f52eae5b465f Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Tue, 15 Mar 2016 14:24:10 +0000 Subject: [PATCH] Update schemas to return more details about the job and template for notifications. --- app/schemas.py | 3 +++ tests/app/notifications/test_rest.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/schemas.py b/app/schemas.py index 4c5fe961a..932fd1990 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -171,6 +171,9 @@ class SmsAdminNotificationSchema(SmsNotificationSchema): class NotificationStatusSchema(BaseSchema): + template = fields.Nested(TemplateSchema, only=["id", "name"], dump_only=True) + job = fields.Nested(JobSchema, only=["id", "file_name"], dump_only=True) + class Meta: model = models.Notification diff --git a/tests/app/notifications/test_rest.py b/tests/app/notifications/test_rest.py index 1d6428e5e..3abe3fc97 100644 --- a/tests/app/notifications/test_rest.py +++ b/tests/app/notifications/test_rest.py @@ -25,7 +25,9 @@ def test_get_notification_by_id(notify_api, sample_notification): notification = json.loads(response.get_data(as_text=True))['notification'] assert notification['status'] == 'sent' - assert notification['template'] == sample_notification.template.id + assert notification['template'] == { + 'id': sample_notification.template.id, + 'name': sample_notification.template.name} assert notification['to'] == '+447700900855' assert notification['service'] == str(sample_notification.service_id) assert response.status_code == 200 @@ -64,7 +66,9 @@ def test_get_all_notifications(notify_api, sample_notification): notifications = json.loads(response.get_data(as_text=True)) assert notifications['notifications'][0]['status'] == 'sent' - assert notifications['notifications'][0]['template'] == sample_notification.template.id + assert notifications['notifications'][0]['template'] == { + 'id': sample_notification.template.id, + 'name': sample_notification.template.name} assert notifications['notifications'][0]['to'] == '+447700900855' assert notifications['notifications'][0]['service'] == str(sample_notification.service_id) assert response.status_code == 200