feat: 从卡片文本提取智能纪要标题
This commit is contained in:
@ -1,7 +1,49 @@
|
||||
from datetime import date
|
||||
from datetime import date, datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from snooper_calendar import fetch_calendar_events
|
||||
from snooper_calendar import (
|
||||
AI_NOTES_CHAT_ID,
|
||||
_extract_topic,
|
||||
fetch_ai_notes_links,
|
||||
fetch_calendar_events,
|
||||
)
|
||||
from snooper_storage import SnifferStorage
|
||||
|
||||
|
||||
def test_extract_topic_from_card_text():
|
||||
text = (
|
||||
"[卡片]\nMeeting recording completed"
|
||||
"Topic: 指数-金科定期AI业务讨论会Owner: 万轶伦"
|
||||
)
|
||||
assert _extract_topic(text) == "指数-金科定期AI业务讨论会"
|
||||
assert _extract_topic("https://efund.feishu.cn/docx/abc") == ""
|
||||
|
||||
|
||||
def test_fetch_ai_notes_links_reads_topic_from_local_content():
|
||||
tz = ZoneInfo("Asia/Shanghai")
|
||||
storage = SnifferStorage(url="sqlite:///:memory:")
|
||||
ts = int(datetime(2026, 11, 17, 14, 0, tzinfo=tz).timestamp())
|
||||
storage.save_message({
|
||||
"msg_id": "minutes-1",
|
||||
"chat_id": AI_NOTES_CHAT_ID,
|
||||
"chat_type": 2,
|
||||
"from_id": "bot",
|
||||
"msg_type": 14,
|
||||
"create_time": ts,
|
||||
"content": (
|
||||
"[卡片]\nMeeting recording completed"
|
||||
"Topic: 指数-金科定期AI业务讨论会Owner: 万轶伦\n"
|
||||
"https://efund.feishu.cn/minutes/abc123"
|
||||
),
|
||||
})
|
||||
|
||||
links = fetch_ai_notes_links(
|
||||
object(), date(2026, 11, 17), tz, storage=storage
|
||||
)
|
||||
|
||||
assert len(links) == 1
|
||||
assert links[0]["url"].startswith("https://efund.feishu.cn/minutes/abc123")
|
||||
assert links[0]["topic"] == "指数-金科定期AI业务讨论会"
|
||||
|
||||
|
||||
class FakeCalendarClient:
|
||||
|
||||
Reference in New Issue
Block a user