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:
@@ -25,6 +25,23 @@ def test_dao_get_reply_to_by_service_id(notify_db_session):
|
||||
assert second_reply_to == results[2]
|
||||
|
||||
|
||||
def test_dao_get_reply_to_by_service_id_does_not_return_archived_reply_tos(notify_db_session):
|
||||
service = create_service()
|
||||
create_reply_to_email(service=service, email_address='something@email.com')
|
||||
create_reply_to_email(service=service, email_address='another@email.com', is_default=False)
|
||||
archived_reply_to = create_reply_to_email(
|
||||
service=service,
|
||||
email_address='second@email.com',
|
||||
is_default=False,
|
||||
archived=True
|
||||
)
|
||||
|
||||
results = dao_get_reply_to_by_service_id(service_id=service.id)
|
||||
|
||||
assert len(results) == 2
|
||||
assert archived_reply_to not in results
|
||||
|
||||
|
||||
def test_add_reply_to_email_address_for_service_creates_first_email_for_service(notify_db_session):
|
||||
service = create_service()
|
||||
add_reply_to_email_address_for_service(service_id=service.id,
|
||||
@@ -163,6 +180,18 @@ def test_dao_get_reply_to_by_id_raises_sqlalchemy_error_when_reply_to_does_not_e
|
||||
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_reply_to_is_archived(sample_service):
|
||||
create_reply_to_email(service=sample_service, email_address='email@address.com')
|
||||
archived_reply_to = create_reply_to_email(
|
||||
service=sample_service,
|
||||
email_address='email_two@address.com',
|
||||
is_default=False,
|
||||
archived=True)
|
||||
|
||||
with pytest.raises(SQLAlchemyError):
|
||||
dao_get_reply_to_by_id(service_id=sample_service.id, reply_to_id=archived_reply_to.id)
|
||||
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user