mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
Merge pull request #155 from alphagov/notification_api_get_update
Update schemas to return more details about the job and template for …
This commit is contained in:
@@ -171,6 +171,9 @@ class SmsAdminNotificationSchema(SmsNotificationSchema):
|
|||||||
|
|
||||||
class NotificationStatusSchema(BaseSchema):
|
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:
|
class Meta:
|
||||||
model = models.Notification
|
model = models.Notification
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,13 @@ def test_get_notification_by_id(notify_api, sample_notification):
|
|||||||
|
|
||||||
notification = json.loads(response.get_data(as_text=True))['notification']
|
notification = json.loads(response.get_data(as_text=True))['notification']
|
||||||
assert notification['status'] == 'sent'
|
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['job'] == {
|
||||||
|
'id': str(sample_notification.job.id),
|
||||||
|
'file_name': sample_notification.job.file_name
|
||||||
|
}
|
||||||
assert notification['to'] == '+447700900855'
|
assert notification['to'] == '+447700900855'
|
||||||
assert notification['service'] == str(sample_notification.service_id)
|
assert notification['service'] == str(sample_notification.service_id)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
@@ -64,7 +70,13 @@ def test_get_all_notifications(notify_api, sample_notification):
|
|||||||
|
|
||||||
notifications = json.loads(response.get_data(as_text=True))
|
notifications = json.loads(response.get_data(as_text=True))
|
||||||
assert notifications['notifications'][0]['status'] == 'sent'
|
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]['job'] == {
|
||||||
|
'id': str(sample_notification.job.id),
|
||||||
|
'file_name': sample_notification.job.file_name
|
||||||
|
}
|
||||||
assert notifications['notifications'][0]['to'] == '+447700900855'
|
assert notifications['notifications'][0]['to'] == '+447700900855'
|
||||||
assert notifications['notifications'][0]['service'] == str(sample_notification.service_id)
|
assert notifications['notifications'][0]['service'] == str(sample_notification.service_id)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|||||||
Reference in New Issue
Block a user