mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Only return non-archived email reply_to addresses
Updated the DAO methods which return a single email reply_to address and all reply_to addresses to only return the non-archived addresses. Changed the type of error that gets raised when using the Admin interface to be BadRequestError instead of a SQLAlchemyError.
This commit is contained in:
@@ -700,6 +700,30 @@ def test_post_email_notification_with_invalid_reply_to_id_returns_400(client, sa
|
||||
assert 'BadRequestError' in resp_json['errors'][0]['error']
|
||||
|
||||
|
||||
def test_post_email_notification_with_archived_reply_to_id_returns_400(client, sample_email_template, mocker):
|
||||
archived_reply_to = create_reply_to_email(
|
||||
sample_email_template.service,
|
||||
'reply_to@test.com',
|
||||
is_default=False,
|
||||
archived=True)
|
||||
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
data = {
|
||||
"email_address": 'test@test.com',
|
||||
"template_id": sample_email_template.id,
|
||||
'email_reply_to_id': archived_reply_to.id
|
||||
}
|
||||
auth_header = create_authorization_header(service_id=sample_email_template.service_id)
|
||||
response = client.post(
|
||||
path="v2/notifications/email",
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 400
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
assert 'email_reply_to_id {} does not exist in database for service id {}'. \
|
||||
format(archived_reply_to.id, sample_email_template.service_id) in resp_json['errors'][0]['message']
|
||||
assert 'BadRequestError' in resp_json['errors'][0]['error']
|
||||
|
||||
|
||||
def test_post_notification_with_document_upload(client, notify_db, notify_db_session, mocker):
|
||||
service = sample_service(notify_db, notify_db_session, permissions=[EMAIL_TYPE, UPLOAD_DOCUMENT])
|
||||
template = create_sample_template(
|
||||
|
||||
Reference in New Issue
Block a user