refactor: depend on LarkAgentX as an external package
This commit is contained in:
@ -7,9 +7,9 @@ from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
|
||||
from larkx.cli import cmd_summarize
|
||||
from larkx.storage import Storage
|
||||
from larkx.summary import (
|
||||
from larksniffer.cli import cmd_summarize
|
||||
from larksniffer.storage import SnifferStorage as Storage
|
||||
from larksniffer.summary import (
|
||||
DEFAULT_MODEL,
|
||||
MagpieClient,
|
||||
SummaryError,
|
||||
@ -277,7 +277,7 @@ def test_storage_selects_only_received_messages_inside_day_and_chat():
|
||||
|
||||
|
||||
def test_yaml_config_resolves_dated_output_paths(tmp_path):
|
||||
from larkx.summary import configured_output_path, load_output_config
|
||||
from larksniffer.summary import configured_output_path, load_output_config
|
||||
|
||||
config_file = tmp_path / "larksniffer.yaml"
|
||||
config_file.write_text(
|
||||
@ -327,7 +327,7 @@ def test_cli_end_to_end_with_synthetic_db_and_fake_magpie(
|
||||
session = FakeSession(
|
||||
completions=[(DEFAULT_MODEL, "单对话摘要"), (DEFAULT_MODEL, "# 合成总结")]
|
||||
)
|
||||
monkeypatch.setattr("larkx.summary.requests.Session", lambda: session)
|
||||
monkeypatch.setattr("larksniffer.summary.requests.Session", lambda: session)
|
||||
output = tmp_path / "summary.md"
|
||||
args = argparse.Namespace(
|
||||
date="2026-11-03",
|
||||
@ -374,7 +374,7 @@ def test_cli_dry_run_exports_records_without_calling_model(
|
||||
)
|
||||
monkeypatch.setenv("LARKX_STORAGE_URL", database_url)
|
||||
session = FakeSession(completions=[(DEFAULT_MODEL, "不应生成")])
|
||||
monkeypatch.setattr("larkx.summary.requests.Session", lambda: session)
|
||||
monkeypatch.setattr("larksniffer.summary.requests.Session", lambda: session)
|
||||
output = tmp_path / "from-yaml" / "2026-11-03.json"
|
||||
config_file = tmp_path / "larksniffer.yaml"
|
||||
config_file.write_text(
|
||||
@ -407,16 +407,16 @@ def test_cli_dry_run_exports_records_without_calling_model(
|
||||
|
||||
|
||||
def test_cli_summarize_prefetches_before_reading(tmp_path, monkeypatch):
|
||||
from larkx.summary import resolve_day as resolve_summary_day
|
||||
from larksniffer.summary import resolve_day as resolve_summary_day
|
||||
|
||||
database_url = f"sqlite:///{tmp_path / 'synthetic.db'}"
|
||||
monkeypatch.setenv("LARKX_STORAGE_URL", database_url)
|
||||
session = FakeSession(
|
||||
completions=[(DEFAULT_MODEL, "单对话摘要"), (DEFAULT_MODEL, "# 合成总结")]
|
||||
)
|
||||
monkeypatch.setattr("larkx.summary.requests.Session", lambda: session)
|
||||
monkeypatch.setattr("larkx.cli.LarkClient", lambda auth: object())
|
||||
monkeypatch.setattr("larkx.cli.LarkAuth", lambda: object())
|
||||
monkeypatch.setattr("larksniffer.summary.requests.Session", lambda: session)
|
||||
monkeypatch.setattr("larksniffer.cli.LarkClient", lambda auth: object())
|
||||
monkeypatch.setattr("larksniffer.cli.LarkAuth", lambda: object())
|
||||
sync_calls = []
|
||||
|
||||
def fake_sync(client, storage, target_day, tz, batch_size=50, chat_ids=None):
|
||||
@ -438,7 +438,7 @@ def test_cli_summarize_prefetches_before_reading(tmp_path, monkeypatch):
|
||||
sync_calls.append({"batch_size": batch_size, "chat_ids": chat_ids})
|
||||
return {"failed": 0, "matched": 1, "saved": 1, "chats": 1, "requests": 1}
|
||||
|
||||
monkeypatch.setattr("larkx.history.sync_all_chats_for_day", fake_sync)
|
||||
monkeypatch.setattr("larksniffer.history.sync_all_chats_for_day", fake_sync)
|
||||
output = tmp_path / "summary.md"
|
||||
args = argparse.Namespace(
|
||||
date="2026-11-03",
|
||||
@ -471,7 +471,7 @@ def test_cli_model_failure_happens_before_storage_is_opened(monkeypatch):
|
||||
def storage_must_not_open():
|
||||
raise AssertionError("模型检查失败时不应打开消息库")
|
||||
|
||||
monkeypatch.setattr("larkx.cli.Storage", storage_must_not_open)
|
||||
monkeypatch.setattr("larksniffer.cli.Storage", storage_must_not_open)
|
||||
args = argparse.Namespace(
|
||||
date="2026-11-03",
|
||||
timezone="Asia/Shanghai",
|
||||
|
||||
Reference in New Issue
Block a user