def get_safelist(service_id): from app.models import (EMAIL_TYPE, MOBILE_TYPE) service = dao_fetch_service_by_id(service_id) if not service: raise InvalidRequest("Service does not exist", status_code=404) safelist = dao_fetch_service_safelist(service.id) return jsonify( email_addresses=[item.recipient for item in safelist if item.recipient_type == EMAIL_TYPE], phone_numbers=[item.recipient for item in safelist if item.recipient_type == MOBILE_TYPE] )
def test_fetch_service_safelist_ignores_other_service(sample_service_safelist): assert len(dao_fetch_service_safelist(uuid.uuid4())) == 0
def test_fetch_service_safelist_gets_safelists(sample_service_safelist): safelist = dao_fetch_service_safelist(sample_service_safelist.service_id) assert len(safelist) == 1 assert safelist[0].id == sample_service_safelist.id