def test_service_can_send_to_recipient_passes_for_whitelisted_recipient_passes(notify_db, notify_db_session, sample_service): sample_service_whitelist(notify_db, notify_db_session, email_address="*****@*****.**") assert service_can_send_to_recipient("*****@*****.**", 'team', sample_service) is None sample_service_whitelist(notify_db, notify_db_session, mobile_number='07513332413') assert service_can_send_to_recipient('07513332413', 'team', sample_service) is None
def test_service_can_send_to_recipient_passes_for_whitelisted_recipient_passes(notify_db, notify_db_session, sample_service): sample_service_whitelist(notify_db, notify_db_session, email_address="*****@*****.**") assert service_can_send_to_recipient("*****@*****.**", 'team', sample_service) is None sample_service_whitelist(notify_db, notify_db_session, mobile_number='6502532222') assert service_can_send_to_recipient('6502532222', 'team', sample_service) is None
def test_service_can_send_to_recipient_fails_when_ignoring_whitelist( notify_db, notify_db_session, sample_service, recipient, ): sample_service_whitelist(notify_db, notify_db_session, **recipient) with pytest.raises(BadRequestError) as exec_info: service_can_send_to_recipient( next(iter(recipient.values())), 'team', sample_service, allow_whitelisted_recipients=False, ) assert exec_info.value.status_code == 400 assert exec_info.value.message == 'Can’t send to this recipient using a team-only API key' assert exec_info.value.fields == []