mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
assert that the response for emails and sms is formatted as expected also moved schemas into subdirectory to make folder more legible
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
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')
|