mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Add endpoint to create pdf letter
This commit is contained in:
@@ -104,7 +104,7 @@ from app.service.service_senders_schema import (
|
|||||||
)
|
)
|
||||||
from app.service.utils import get_whitelist_objects
|
from app.service.utils import get_whitelist_objects
|
||||||
from app.service.sender import send_notification_to_service_users
|
from app.service.sender import send_notification_to_service_users
|
||||||
from app.service.send_notification import send_one_off_notification
|
from app.service.send_notification import send_one_off_notification, send_pdf_letter_notification
|
||||||
from app.schemas import (
|
from app.schemas import (
|
||||||
service_schema,
|
service_schema,
|
||||||
api_key_schema,
|
api_key_schema,
|
||||||
@@ -648,6 +648,12 @@ def create_one_off_notification(service_id):
|
|||||||
return jsonify(resp), 201
|
return jsonify(resp), 201
|
||||||
|
|
||||||
|
|
||||||
|
@service_blueprint.route('/<uuid:service_id>/send-pdf-letter', methods=['POST'])
|
||||||
|
def create_pdf_letter(service_id):
|
||||||
|
resp = send_pdf_letter_notification(service_id, request.get_json())
|
||||||
|
return jsonify(resp), 201
|
||||||
|
|
||||||
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/email-reply-to', methods=["GET"])
|
@service_blueprint.route('/<uuid:service_id>/email-reply-to', methods=["GET"])
|
||||||
def get_email_reply_to_addresses(service_id):
|
def get_email_reply_to_addresses(service_id):
|
||||||
result = dao_get_reply_to_by_service_id(service_id)
|
result = dao_get_reply_to_by_service_id(service_id)
|
||||||
|
|||||||
@@ -2273,6 +2273,29 @@ def test_send_one_off_notification(sample_service, admin_request, mocker):
|
|||||||
assert response['id'] == str(noti.id)
|
assert response['id'] == str(noti.id)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_pdf_letter(mocker, sample_service_full_permissions, client, fake_uuid, notify_user):
|
||||||
|
mocker.patch('app.service.send_notification.utils_s3download')
|
||||||
|
mocker.patch('app.service.send_notification.get_page_count', return_value=1)
|
||||||
|
mocker.patch('app.service.send_notification.move_uploaded_pdf_to_letters_bucket')
|
||||||
|
|
||||||
|
user = sample_service_full_permissions.users[0]
|
||||||
|
data = json.dumps({
|
||||||
|
'filename': 'valid.pdf',
|
||||||
|
'created_by': str(user.id),
|
||||||
|
'file_id': fake_uuid
|
||||||
|
})
|
||||||
|
|
||||||
|
response = client.post(
|
||||||
|
url_for('service.create_pdf_letter', service_id=sample_service_full_permissions.id),
|
||||||
|
data=data,
|
||||||
|
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||||
|
)
|
||||||
|
json_resp = json.loads(response.get_data(as_text=True))
|
||||||
|
|
||||||
|
assert response.status_code == 201
|
||||||
|
assert json_resp == {'id': fake_uuid}
|
||||||
|
|
||||||
|
|
||||||
def test_get_notification_for_service_includes_template_redacted(admin_request, sample_notification):
|
def test_get_notification_for_service_includes_template_redacted(admin_request, sample_notification):
|
||||||
resp = admin_request.get(
|
resp = admin_request.get(
|
||||||
'service.get_notification_for_service',
|
'service.get_notification_for_service',
|
||||||
|
|||||||
Reference in New Issue
Block a user