sync update from LAN repo (source master @ ca48c4ec)

This commit is contained in:
gozeros committed 2026-11-05 10:53:54 +08:00
1 parent 8bc8b0e082
commit ea9dcff9c0
873 files changed
+107866 -14011

No files matched your search

@@ -657,10 +657,66 @@ async def test_auto_sync_scheduler_refreshes_provider_between_syncs(monkeypatch)
assert syncs == ["openai", "local"]
def test_local_wiki_index_defaults_to_automatic_sync() -> None:
@pytest.mark.asyncio
async def test_disabled_auto_sync_keeps_scheduler_local_only(monkeypatch) -> None:
now = 0.0
refreshes: list[float] = []
syncs: list[float] = []
remote_maintenance_calls: list[str] = []
config = SimpleNamespace(
enabled=True,
auto_sync=False,
sync_interval_seconds=25,
)
async def fake_refresh(_app):
refreshes.append(now)
return config
async def fake_sleep(seconds: float) -> None:
nonlocal now
now += seconds
if len(refreshes) >= 3:
raise asyncio.CancelledError
async def fake_sync_once(_app, *, config=None) -> None:
syncs.append(now)
async def fake_remote_maintenance(_app) -> None:
remote_maintenance_calls.append("called")
monkeypatch.setattr(llmwiki_index_scheduler, "monotonic", lambda: now)
monkeypatch.setattr(llmwiki_index_scheduler.asyncio, "sleep", fake_sleep)
monkeypatch.setattr(llmwiki_index_scheduler, "_sync_once", fake_sync_once)
monkeypatch.setattr(
llmwiki_index_scheduler,
"_upgrade_wiki_generation_configs_once",
fake_remote_maintenance,
)
monkeypatch.setattr(
llmwiki_index_scheduler,
"_refresh_local_wiki_config",
fake_refresh,
)
app = SimpleNamespace(
state=SimpleNamespace(
llmwiki_sync_service=object(),
llmwiki_store=object(),
)
)
with pytest.raises(asyncio.CancelledError):
await llmwiki_index_scheduler.local_wiki_index_scheduler_loop(app)
assert refreshes == [0.0, 10.0, 20.0]
assert syncs == []
assert remote_maintenance_calls == []
def test_local_wiki_index_defaults_to_manual_sync() -> None:
config = LocalWikiIndexConfig()
assert config.auto_sync is True
assert config.auto_sync is False
assert config.sync_interval_seconds == 30