from pyra.security.injection import InjectionWarning def test_render_text_response_passthrough(): from pyra.chat.renderer import render_text_response result = render_text_response("Hello world") assert result == "Hello world" def test_render_text_response_redacts_api_key(): from pyra.chat.renderer import render_text_response # anthropic-style key result = render_text_response("key: sk-ant-api03-abcdefghijklmnopqrstuvwxyz123456") assert "sk-ant" not in result assert "[REDACTED]" in result def test_render_text_response_empty_string(): from pyra.chat.renderer import render_text_response result = render_text_response("") assert result == "" def test_render_text_response_whitespace_only(): from pyra.chat.renderer import render_text_response result = render_text_response(" ") assert result == " " def test_render_error_no_exception(): from pyra.chat.renderer import render_error render_error("Something went wrong") def test_render_info_no_exception(): from pyra.chat.renderer import render_info render_info("Informational message") def test_render_system_no_exception(): from pyra.chat.renderer import render_system render_system("System message") def test_render_injection_warning_no_exception(): from pyra.chat.renderer import render_injection_warning warnings = [InjectionWarning(pattern_label="instruction-override", matched_text="ignore all")] render_injection_warning(warnings) def test_render_injection_warning_multiple(): from pyra.chat.renderer import render_injection_warning warnings = [ InjectionWarning(pattern_label="instruction-override", matched_text="ignore"), InjectionWarning(pattern_label="jailbreak", matched_text="DAN mode"), ] render_injection_warning(warnings)