mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 17:38:02 -04:00
Add get letter contact by id endpoint
Added the GET /<uuid:service_id>/letter-contact/<uuid:letter_contact_id> endpoint for returning a letter contact for a service with the letter contact id Added the DAO for returning a letter contact by id
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import uuid
|
||||
import pytest
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app.dao.service_letter_contact_dao import (
|
||||
add_letter_contact_for_service,
|
||||
create_or_update_letter_contact,
|
||||
dao_get_letter_contacts_by_service_id,
|
||||
dao_get_letter_contact_by_id,
|
||||
update_letter_contact
|
||||
)
|
||||
from app.errors import InvalidRequest
|
||||
@@ -202,3 +205,20 @@ def test_update_letter_contact_unset_default_for_only_letter_contact_raises_exce
|
||||
contact_block='Warwick, W14 TSR',
|
||||
is_default=False
|
||||
)
|
||||
|
||||
|
||||
def test_dao_get_letter_contact_by_id(sample_service):
|
||||
letter_contact = create_letter_contact(service=sample_service, contact_block='Aberdeen, AB12 23X')
|
||||
result = dao_get_letter_contact_by_id(service_id=sample_service.id, letter_contact_id=letter_contact.id)
|
||||
assert result == letter_contact
|
||||
|
||||
|
||||
def test_dao_get_letter_contact_by_id_raises_sqlalchemy_error_when_letter_contact_does_not_exist(sample_service):
|
||||
with pytest.raises(SQLAlchemyError):
|
||||
dao_get_letter_contact_by_id(service_id=sample_service.id, letter_contact_id=uuid.uuid4())
|
||||
|
||||
|
||||
def test_dao_get_letter_contact_by_id_raises_sqlalchemy_error_when_service_does_not_exist(sample_service):
|
||||
letter_contact = create_letter_contact(service=sample_service, contact_block='Some address')
|
||||
with pytest.raises(SQLAlchemyError):
|
||||
dao_get_letter_contact_by_id(service_id=uuid.uuid4(), letter_contact_id=letter_contact.id)
|
||||
|
||||
Reference in New Issue
Block a user