mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
add public contract tests
use jsonschema to test the GET /notification/{} endpoint to highlight any key name/format/type changes
This commit is contained in:
30
tests/app/public_contracts/test_GET_notification.py
Normal file
30
tests/app/public_contracts/test_GET_notification.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
from flask import json
|
||||
import jsonschema
|
||||
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
def test_get_sms_contract(client, sample_notification):
|
||||
auth_header = create_authorization_header(service_id=sample_notification.service_id)
|
||||
response = client.get('/notifications/{}'.format(sample_notification.id), headers=[auth_header])
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), './GET_notification_return_sms.json')) as schema:
|
||||
jsonschema.validate(
|
||||
json.loads(response.get_data(as_text=True)),
|
||||
json.load(schema),
|
||||
format_checker=jsonschema.FormatChecker()
|
||||
)
|
||||
|
||||
|
||||
def test_get_email_contract(client, sample_email_notification):
|
||||
auth_header = create_authorization_header(service_id=sample_email_notification.service_id)
|
||||
response = client.get('/notifications/{}'.format(sample_email_notification.id), headers=[auth_header])
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), './GET_notification_return_email.json')) as schema:
|
||||
jsonschema.validate(
|
||||
json.loads(response.get_data(as_text=True)),
|
||||
json.load(schema),
|
||||
format_checker=jsonschema.FormatChecker()
|
||||
)
|
||||
Reference in New Issue
Block a user