Include utility modules, shared channels, prompts, read-only skills, wardrobe memory and regression tests. Externalize legacy credentials and exclude private runtime state.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import os
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import mail
|
|
|
|
|
|
class MailReferenceTest(unittest.TestCase):
|
|
def test_latest_event_reference_and_explicit_id(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
history = Path(tmp) / "chat" / "history"
|
|
history.mkdir(parents=True)
|
|
(history / "1.txt").write_text(
|
|
"[event:mail:2644] old\n[event:mail:2645] newest\n", encoding="utf-8")
|
|
with patch.object(mail, "BASE_DIR", tmp):
|
|
self.assertEqual(
|
|
mail.resolve_context_reference(1, "帮我查看一下这篇邮件说了什么"),
|
|
"帮我查看一下编号为 2645 的邮件说了什么")
|
|
self.assertEqual(
|
|
mail.resolve_context_reference(1, "查看编号2644的邮件"),
|
|
"查看编号2644的邮件")
|
|
|
|
def test_missing_history_is_not_guessed(self):
|
|
with tempfile.TemporaryDirectory() as tmp, patch.object(mail, "BASE_DIR", tmp):
|
|
text = "帮我查看一下这篇邮件说了什么"
|
|
self.assertEqual(mail.resolve_context_reference(1, text), text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|