New endpoint to fetch a single reply-to email address by id

This commit is contained in:
Rebecca Law
2017-09-21 17:02:58 +01:00
parent e6d6b6f985
commit 795bd4271c
4 changed files with 49 additions and 2 deletions

View File

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