mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
add test for GET /notification
simple schema with oneOf [email, sms]. also fixed error where ref'd schemas weren't being picked up
This commit is contained in:
@@ -8,8 +8,10 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"notification": {"$ref": "email_notification.json"}
|
"notification": {"$ref": "email_notification.json"}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false,
|
||||||
|
"required": ["notification"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false,
|
||||||
|
"required": ["data"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"notification": {"$ref": "sms_notification.json"}
|
"notification": {"$ref": "sms_notification.json"}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false,
|
||||||
|
"required": ["notification"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false,
|
||||||
|
"required": ["data"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"description": "GET notification return schema - for sms notifications",
|
||||||
|
"type" : "object",
|
||||||
|
"properties": {
|
||||||
|
"notifications": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"oneOf": [
|
||||||
|
{"$ref": "sms_notification.json"},
|
||||||
|
{"$ref": "email_notification.json"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"links": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"page_size": {"type": "number"},
|
||||||
|
"total": {"type": "number"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"notifications", "links", "page_size", "total"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,5 +8,5 @@
|
|||||||
"datetime": {
|
"datetime": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time"
|
"format": "date-time"
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,108 +1,106 @@
|
|||||||
{
|
{
|
||||||
"email_notification": {
|
"description": "Single email notification schema - as returned by GET /notification and GET /notification/{}",
|
||||||
"description": "Single email notification schema - as returned by GET /notification and GET /notification/{}",
|
"type": "object",
|
||||||
"type": "object",
|
"properties": {
|
||||||
"properties": {
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
"to": {"type": "string", "format": "email"},
|
||||||
"to": {"type": "string", "format": "email"},
|
"job_row_number": {"oneOf":[
|
||||||
"job_row_number": {"oneOf":[
|
{"type": "number"},
|
||||||
{"type": "number"},
|
{"type": "null"}
|
||||||
{"type": "null"}
|
]},
|
||||||
]},
|
"template_version": {"type": "number"},
|
||||||
"template_version": {"type": "number"},
|
"billable_units": {"type": "number"},
|
||||||
"billable_units": {"type": "number"},
|
"notification_type": {
|
||||||
"notification_type": {
|
"type": "string",
|
||||||
"type": "string",
|
"enum": ["email"]
|
||||||
"enum": ["email"]
|
|
||||||
},
|
|
||||||
"created_at": {"$ref": "definitions.json#/datetime"},
|
|
||||||
"sent_at": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/datetime"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"sent_by": {"oneOf":[
|
|
||||||
{"type": "string"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"updated_at": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/datetime"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"status": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"created",
|
|
||||||
"sending",
|
|
||||||
"delivered",
|
|
||||||
"pending",
|
|
||||||
"failed",
|
|
||||||
"technical-failure",
|
|
||||||
"temporary-failure",
|
|
||||||
"permanent-failure"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"reference": {"oneOf":[
|
|
||||||
{"type": "string"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"template": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"name": {"type": "string"},
|
|
||||||
"template_type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["email"]
|
|
||||||
},
|
|
||||||
"version": {"type": "number"}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": ["id", "name", "template_type", "version"]
|
|
||||||
},
|
|
||||||
"service": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"job": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"original_file_name": {"type": "string"}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": ["id", "original_file_name"]
|
|
||||||
},
|
|
||||||
{"type": "null"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"api_key": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/uuid"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"body": {"type": "string"},
|
|
||||||
"content_char_count": {"type": "null"},
|
|
||||||
"subject": {"type": "string"}
|
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"created_at": {"$ref": "definitions.json#/datetime"},
|
||||||
"required": [
|
"sent_at": {"oneOf":[
|
||||||
"id",
|
{"$ref": "definitions.json#/datetime"},
|
||||||
"to",
|
{"type": "null"}
|
||||||
"job_row_number",
|
]},
|
||||||
"template_version",
|
"sent_by": {"oneOf":[
|
||||||
"billable_units",
|
{"type": "string"},
|
||||||
"notification_type",
|
{"type": "null"}
|
||||||
"created_at",
|
]},
|
||||||
"sent_at",
|
"updated_at": {"oneOf":[
|
||||||
"sent_by",
|
{"$ref": "definitions.json#/datetime"},
|
||||||
"updated_at",
|
{"type": "null"}
|
||||||
"status",
|
]},
|
||||||
"reference",
|
"status": {
|
||||||
"template",
|
"type": "string",
|
||||||
"service",
|
"enum": [
|
||||||
"job",
|
"created",
|
||||||
"api_key",
|
"sending",
|
||||||
"body",
|
"delivered",
|
||||||
"content_char_count",
|
"pending",
|
||||||
"subject"
|
"failed",
|
||||||
]
|
"technical-failure",
|
||||||
}
|
"temporary-failure",
|
||||||
|
"permanent-failure"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reference": {"oneOf":[
|
||||||
|
{"type": "string"},
|
||||||
|
{"type": "null"}
|
||||||
|
]},
|
||||||
|
"template": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"name": {"type": "string"},
|
||||||
|
"template_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["email"]
|
||||||
|
},
|
||||||
|
"version": {"type": "number"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["id", "name", "template_type", "version"]
|
||||||
|
},
|
||||||
|
"service": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"job": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"original_file_name": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["id", "original_file_name"]
|
||||||
|
},
|
||||||
|
{"type": "null"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"api_key": {"oneOf":[
|
||||||
|
{"$ref": "definitions.json#/uuid"},
|
||||||
|
{"type": "null"}
|
||||||
|
]},
|
||||||
|
"body": {"type": "string"},
|
||||||
|
"content_char_count": {"type": "null"},
|
||||||
|
"subject": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"to",
|
||||||
|
"job_row_number",
|
||||||
|
"template_version",
|
||||||
|
"billable_units",
|
||||||
|
"notification_type",
|
||||||
|
"created_at",
|
||||||
|
"sent_at",
|
||||||
|
"sent_by",
|
||||||
|
"updated_at",
|
||||||
|
"status",
|
||||||
|
"reference",
|
||||||
|
"template",
|
||||||
|
"service",
|
||||||
|
"job",
|
||||||
|
"api_key",
|
||||||
|
"body",
|
||||||
|
"content_char_count",
|
||||||
|
"subject"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,106 +1,104 @@
|
|||||||
{
|
{
|
||||||
"sms_notification": {
|
"description": "Single sms notification schema - as returned by GET /notification and GET /notification/{}",
|
||||||
"description": "Single sms notification schema - as returned by GET /notification and GET /notification/{}",
|
"type": "object",
|
||||||
"type": "object",
|
"properties": {
|
||||||
"properties": {
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
"to": {"type": "string"},
|
||||||
"to": {"type": "string"},
|
"job_row_number": {"oneOf":[
|
||||||
"job_row_number": {"oneOf":[
|
{"type": "number"},
|
||||||
{"type": "number"},
|
{"type": "null"}
|
||||||
{"type": "null"}
|
]},
|
||||||
]},
|
"template_version": {"type": "number"},
|
||||||
"template_version": {"type": "number"},
|
"billable_units": {"type": "number"},
|
||||||
"billable_units": {"type": "number"},
|
"notification_type": {
|
||||||
"notification_type": {
|
"type": "string",
|
||||||
"type": "string",
|
"enum": ["sms"]
|
||||||
"enum": ["sms"]
|
|
||||||
},
|
|
||||||
"created_at": {"$ref": "definitions.json#/datetime"},
|
|
||||||
"sent_at": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/datetime"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"sent_by": {"oneOf":[
|
|
||||||
{"type": "string"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"updated_at": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/datetime"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"status": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"created",
|
|
||||||
"sending",
|
|
||||||
"delivered",
|
|
||||||
"pending",
|
|
||||||
"failed",
|
|
||||||
"technical-failure",
|
|
||||||
"temporary-failure",
|
|
||||||
"permanent-failure"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"reference": {"oneOf":[
|
|
||||||
{"type": "string"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"template": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"name": {"type": "string"},
|
|
||||||
"template_type": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": ["sms"]
|
|
||||||
},
|
|
||||||
"version": {"type": "number"}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": ["id", "name", "template_type", "version"]
|
|
||||||
},
|
|
||||||
"service": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"job": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"$ref": "definitions.json#/uuid"},
|
|
||||||
"original_file_name": {"type": "string"}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": ["id", "original_file_name"]
|
|
||||||
},
|
|
||||||
{"type": "null"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"api_key": {"oneOf":[
|
|
||||||
{"$ref": "definitions.json#/uuid"},
|
|
||||||
{"type": "null"}
|
|
||||||
]},
|
|
||||||
"body": {"type": "string"},
|
|
||||||
"content_char_count": {"type": "null"}
|
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"created_at": {"$ref": "definitions.json#/datetime"},
|
||||||
"required": [
|
"sent_at": {"oneOf":[
|
||||||
"id",
|
{"$ref": "definitions.json#/datetime"},
|
||||||
"to",
|
{"type": "null"}
|
||||||
"job_row_number",
|
]},
|
||||||
"template_version",
|
"sent_by": {"oneOf":[
|
||||||
"billable_units",
|
{"type": "string"},
|
||||||
"notification_type",
|
{"type": "null"}
|
||||||
"created_at",
|
]},
|
||||||
"sent_at",
|
"updated_at": {"oneOf":[
|
||||||
"sent_by",
|
{"$ref": "definitions.json#/datetime"},
|
||||||
"updated_at",
|
{"type": "null"}
|
||||||
"status",
|
]},
|
||||||
"reference",
|
"status": {
|
||||||
"template",
|
"type": "string",
|
||||||
"service",
|
"enum": [
|
||||||
"job",
|
"created",
|
||||||
"api_key",
|
"sending",
|
||||||
"body",
|
"delivered",
|
||||||
"content_char_count"
|
"pending",
|
||||||
]
|
"failed",
|
||||||
}
|
"technical-failure",
|
||||||
|
"temporary-failure",
|
||||||
|
"permanent-failure"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reference": {"oneOf":[
|
||||||
|
{"type": "string"},
|
||||||
|
{"type": "null"}
|
||||||
|
]},
|
||||||
|
"template": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"name": {"type": "string"},
|
||||||
|
"template_type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["sms"]
|
||||||
|
},
|
||||||
|
"version": {"type": "number"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["id", "name", "template_type", "version"]
|
||||||
|
},
|
||||||
|
"service": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"job": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"$ref": "definitions.json#/uuid"},
|
||||||
|
"original_file_name": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["id", "original_file_name"]
|
||||||
|
},
|
||||||
|
{"type": "null"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"api_key": {"oneOf":[
|
||||||
|
{"$ref": "definitions.json#/uuid"},
|
||||||
|
{"type": "null"}
|
||||||
|
]},
|
||||||
|
"body": {"type": "string"},
|
||||||
|
"content_char_count": {"type": "number"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"to",
|
||||||
|
"job_row_number",
|
||||||
|
"template_version",
|
||||||
|
"billable_units",
|
||||||
|
"notification_type",
|
||||||
|
"created_at",
|
||||||
|
"sent_at",
|
||||||
|
"sent_by",
|
||||||
|
"updated_at",
|
||||||
|
"status",
|
||||||
|
"reference",
|
||||||
|
"template",
|
||||||
|
"service",
|
||||||
|
"job",
|
||||||
|
"api_key",
|
||||||
|
"body",
|
||||||
|
"content_char_count"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,3 +27,10 @@ def test_get_email_contract(client, sample_email_notification):
|
|||||||
response = client.get('/notifications/{}'.format(sample_email_notification.id), headers=[auth_header])
|
response = client.get('/notifications/{}'.format(sample_email_notification.id), headers=[auth_header])
|
||||||
|
|
||||||
validate(response.get_data(as_text=True), './GET_notification_return_email.json')
|
validate(response.get_data(as_text=True), './GET_notification_return_email.json')
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_notifications_contract(client, sample_notification, sample_email_notification):
|
||||||
|
auth_header = create_authorization_header(service_id=sample_notification.service_id)
|
||||||
|
response = client.get('/notifications', headers=[auth_header])
|
||||||
|
|
||||||
|
validate(response.get_data(as_text=True), './GET_notifications_return.json')
|
||||||
|
|||||||
Reference in New Issue
Block a user