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:
Katie Smith
2018-04-25 12:19:12 +01:00
parent be28f2e2de
commit a57b2f50c2
6 changed files with 71 additions and 7 deletions

View File

@@ -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):