mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
New endpoint to fetch a single reply-to email address by id
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app.dao.service_email_reply_to_dao import (
|
||||
create_or_update_email_reply_to,
|
||||
dao_get_reply_to_by_service_id,
|
||||
add_reply_to_email_address_for_service, update_reply_to_email_address)
|
||||
add_reply_to_email_address_for_service, update_reply_to_email_address, dao_get_reply_to_by_id)
|
||||
from app.errors import InvalidRequest
|
||||
from app.models import ServiceEmailReplyTo
|
||||
from tests.app.db import create_reply_to_email, create_service
|
||||
@@ -191,3 +194,20 @@ def test_update_reply_to_email_address_raises_exception_if_single_reply_to_and_s
|
||||
reply_to_id=first_reply_to.id,
|
||||
email_address='should@fail.com',
|
||||
is_default=False)
|
||||
|
||||
|
||||
def test_dao_get_reply_to_by_id(sample_service):
|
||||
reply_to = create_reply_to_email(service=sample_service, email_address='email@address.com')
|
||||
result = dao_get_reply_to_by_id(service_id=sample_service.id, reply_to_id=reply_to.id)
|
||||
assert result == reply_to
|
||||
|
||||
|
||||
def test_dao_get_reply_to_by_id_raises_sqlalchemy_error_when_reply_to_does_not_exist(sample_service):
|
||||
with pytest.raises(SQLAlchemyError):
|
||||
dao_get_reply_to_by_id(service_id=sample_service.id, reply_to_id=uuid.uuid4())
|
||||
|
||||
|
||||
def test_dao_get_reply_to_by_id_raises_sqlalchemy_error_when_service_does_not_exist(sample_service):
|
||||
reply_to = create_reply_to_email(service=sample_service, email_address='email@address.com')
|
||||
with pytest.raises(SQLAlchemyError):
|
||||
dao_get_reply_to_by_id(service_id=uuid.uuid4(), reply_to_id=reply_to.id)
|
||||
|
||||
@@ -2290,3 +2290,14 @@ def test_update_service_reply_to_email_address_404s_when_invalid_service_id(clie
|
||||
result = json.loads(response.get_data(as_text=True))
|
||||
assert result['result'] == 'error'
|
||||
assert result['message'] == 'No result found'
|
||||
|
||||
|
||||
def test_get_email_reply_to_address(client, notify_db, notify_db_session):
|
||||
service = create_service(notify_db=notify_db, notify_db_session=notify_db_session)
|
||||
reply_to = create_reply_to_email(service, 'test_a@mail.com')
|
||||
|
||||
response = client.get('/service/{}/email-reply-to/{}'.format(service.id, reply_to.id),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()])
|
||||
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == reply_to.serialize()
|
||||
|
||||
Reference in New Issue
Block a user