mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
add POST response tests
assert that the response for emails and sms is formatted as expected also moved schemas into subdirectory to make folder more legible
This commit is contained in:
44
tests/app/public_contracts/test_POST_notification.py
Normal file
44
tests/app/public_contracts/test_POST_notification.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from flask import json
|
||||
|
||||
from . import validate
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
def test_post_sms_contract(client, mocker, sample_template):
|
||||
mocker.patch('app.celery.tasks.send_sms.apply_async')
|
||||
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
|
||||
|
||||
data = {
|
||||
'to': '07700 900 855',
|
||||
'template': str(sample_template.id)
|
||||
}
|
||||
|
||||
auth_header = create_authorization_header(service_id=sample_template.service_id)
|
||||
|
||||
response = client.post(
|
||||
path='/notifications/sms',
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header]
|
||||
)
|
||||
|
||||
validate(response.get_data(as_text=True), 'POST_notification_return_sms.json')
|
||||
|
||||
|
||||
def test_post_email_contract(client, mocker, sample_email_template):
|
||||
mocker.patch('app.celery.tasks.send_sms.apply_async')
|
||||
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
|
||||
|
||||
data = {
|
||||
'to': 'foo@bar.com',
|
||||
'template': str(sample_email_template.id)
|
||||
}
|
||||
|
||||
auth_header = create_authorization_header(service_id=sample_email_template.service_id)
|
||||
|
||||
response = client.post(
|
||||
path='/notifications/email',
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header]
|
||||
)
|
||||
|
||||
validate(response.get_data(as_text=True), 'POST_notification_return_email.json')
|
||||
Reference in New Issue
Block a user