mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Add get_notifications json schema + tests
Add a schema that corresponds to our response for returning lists of notifications, and test with a contract test.
This commit is contained in:
@@ -72,6 +72,36 @@ get_notification_response = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_notifications_response = {
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"description": "GET list of notifications response schema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"notifications": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"ref": get_notification_response
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"links": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"current": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"next": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": False,
|
||||||
|
"required": ["current"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": False,
|
||||||
|
"required": ["notifications", "links"]
|
||||||
|
}
|
||||||
|
|
||||||
post_sms_request = {
|
post_sms_request = {
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"description": "POST sms notification schema",
|
"description": "POST sms notification schema",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from . import return_json_from_response, validate_v0, validate
|
from . import return_json_from_response, validate_v0, validate
|
||||||
from app.models import ApiKey, KEY_TYPE_NORMAL
|
from app.models import ApiKey, KEY_TYPE_NORMAL
|
||||||
from app.dao.api_key_dao import save_model_api_key
|
from app.dao.api_key_dao import save_model_api_key
|
||||||
from app.v2.notifications.notification_schemas import get_notification_response
|
from app.v2.notifications.notification_schemas import get_notification_response, get_notifications_response
|
||||||
from tests import create_authorization_header
|
from tests import create_authorization_header
|
||||||
|
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@ def _get_notification(client, notification, url):
|
|||||||
return client.get(url, headers=[auth_header])
|
return client.get(url, headers=[auth_header])
|
||||||
|
|
||||||
|
|
||||||
|
# v2
|
||||||
|
|
||||||
def test_get_v2_sms_contract(client, sample_notification):
|
def test_get_v2_sms_contract(client, sample_notification):
|
||||||
response_json = return_json_from_response(_get_notification(
|
response_json = return_json_from_response(_get_notification(
|
||||||
client, sample_notification, '/v2/notifications/{}'.format(sample_notification.id)
|
client, sample_notification, '/v2/notifications/{}'.format(sample_notification.id)
|
||||||
@@ -30,6 +32,15 @@ def test_get_v2_email_contract(client, sample_email_notification):
|
|||||||
validate(response_json, get_notification_response)
|
validate(response_json, get_notification_response)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_v2_notifications_contract(client, sample_notification):
|
||||||
|
response_json = return_json_from_response(_get_notification(
|
||||||
|
client, sample_notification, '/v2/notifications'
|
||||||
|
))
|
||||||
|
validate(response_json, get_notifications_response)
|
||||||
|
|
||||||
|
|
||||||
|
# v0
|
||||||
|
|
||||||
def test_get_api_sms_contract(client, sample_notification):
|
def test_get_api_sms_contract(client, sample_notification):
|
||||||
response_json = return_json_from_response(_get_notification(
|
response_json = return_json_from_response(_get_notification(
|
||||||
client, sample_notification, '/notifications/{}'.format(sample_notification.id)
|
client, sample_notification, '/notifications/{}'.format(sample_notification.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user