# tests/test_discord_handler.py import pytest from unittest.mock import MagicMock, AsyncMock def test_parse_discord_mention_with_issue(): """이슈 번호가 포함된 Discord 멘션을 파싱한다.""" from agent.integrations.discord_handler import parse_discord_message result = parse_discord_message("이슈 #42 해결해줘", bot_user_id=123) assert result["issue_number"] == 42 assert result["repo_name"] == "galaxis-po" assert "해결해줘" in result["message"] def test_parse_discord_mention_with_repo(): """리포가 명시된 Discord 멘션을 파싱한다.""" from agent.integrations.discord_handler import parse_discord_message result = parse_discord_message("galaxis-po 이슈 #10 수정해줘", bot_user_id=123) assert result["issue_number"] == 10 assert result["repo_name"] == "galaxis-po" def test_parse_discord_mention_freeform(): """이슈 번호 없는 자유형 요청을 파싱한다.""" from agent.integrations.discord_handler import parse_discord_message result = parse_discord_message("factor_calculator에 듀얼 모멘텀 추가해줘", bot_user_id=123) assert result["issue_number"] == 0 assert result["message"] == "factor_calculator에 듀얼 모멘텀 추가해줘" def test_generate_discord_thread_id(): """Discord 메시지에서 결정론적 thread_id를 생성한다.""" from agent.integrations.discord_handler import generate_discord_thread_id tid1 = generate_discord_thread_id(channel_id=111, message_id=222) tid2 = generate_discord_thread_id(channel_id=111, message_id=222) tid3 = generate_discord_thread_id(channel_id=111, message_id=333) assert tid1 == tid2 assert tid1 != tid3 assert len(tid1) == 36