Files
hermes-agent/tests/test_crisis_resources.py
Timmy Time 34e7de6a4c
Some checks failed
Supply Chain Audit / Scan PR for supply chain risks (pull_request) Successful in 18s
Contributor Attribution Check / check-attribution (pull_request) Failing after 17s
Docker Build and Publish / build-and-push (pull_request) Has been skipped
Tests / test (pull_request) Failing after 18m18s
Tests / e2e (pull_request) Successful in 1m13s
feat: 988 Lifeline tests (#673)
2026-04-17 05:04:50 +00:00

80 lines
2.2 KiB
Python

"""Tests for 988 Crisis Lifeline integration (#673)."""
import pytest
from agent.crisis_resources import (
LIFELINE_988,
LIFELINE_988_TEXT,
LIFELINE_988_CHAT,
LIFELINE_988_SPANISH,
CRISIS_TEXT_LINE,
EMERGENCY_911,
ALL_RESOURCES,
get_crisis_resources,
format_crisis_resources,
get_immediate_help_message,
CrisisResource,
)
class TestCrisisResources:
def test_988_phone(self):
assert "988" in LIFELINE_988.contact
assert "24/7" in LIFELINE_988.available
def test_988_text(self):
assert "HOME" in LIFELINE_988_TEXT.contact
assert "988" in LIFELINE_988_TEXT.contact
def test_988_chat(self):
assert "988lifeline.org/chat" in LIFELINE_988_CHAT.url
def test_988_spanish(self):
assert "1-888-628-9454" in LIFELINE_988_SPANISH.contact
assert LIFELINE_988_SPANISH.language == "Spanish"
def test_crisis_text_line(self):
assert "741741" in CRISIS_TEXT_LINE.contact
def test_911(self):
assert "911" in EMERGENCY_911.contact
def test_all_resources_not_empty(self):
assert len(ALL_RESOURCES) >= 5
class TestGetResources:
def test_returns_all_by_default(self):
assert len(get_crisis_resources()) == len(ALL_RESOURCES)
def test_filter_english(self):
english = get_crisis_resources("English")
assert all(r.language == "English" for r in english)
assert len(english) > 0
def test_filter_spanish(self):
spanish = get_crisis_resources("Spanish")
assert len(spanish) >= 1
assert all(r.language == "Spanish" for r in spanish)
class TestFormatting:
def test_format_includes_988(self):
msg = format_crisis_resources()
assert "988" in msg
def test_format_includes_741741(self):
msg = format_crisis_resources()
assert "741741" in msg
def test_format_includes_911(self):
msg = format_crisis_resources()
assert "911" in msg
def test_immediate_help_includes_911_first(self):
msg = get_immediate_help_message()
assert msg.startswith("If you are in immediate danger")
def test_format_not_empty(self):
msg = format_crisis_resources()
assert len(msg) > 100