sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
@@ -513,6 +513,43 @@ async def test_list_bases_does_not_trigger_full_library_alignment(
|
||||
align.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("custom", [False, True])
|
||||
async def test_browsing_committed_pages_does_not_wait_for_background_import(
|
||||
repository: AssistantKnowledgeRepository,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
custom: bool,
|
||||
) -> None:
|
||||
base = await repository.initialize(created_by="admin")
|
||||
if custom:
|
||||
base = await repository.create_base(created_by="admin", name="独立助手库")
|
||||
await repository.import_package(
|
||||
package={"wiki_pages": [{"slug": "wiki/ready", "title": "已提交内容", "content": "上次成功导入的正文"}]},
|
||||
source_type="weknora",
|
||||
source_key="ready-source",
|
||||
source_name="已完成来源",
|
||||
trigger="manual_package_upload",
|
||||
created_by="admin",
|
||||
base_id=base["id"],
|
||||
)
|
||||
# A fresh Gateway has an empty alignment cache. A different import may
|
||||
# already own the write lock, but readers must still see the old snapshot.
|
||||
reader = AssistantKnowledgeRepository(repository._sf)
|
||||
counters = AsyncMock(side_effect=AssertionError("content reads must not scan library counters"))
|
||||
monkeypatch.setattr(reader, "_base_stats_by_ids", counters)
|
||||
async with reader._import_lock:
|
||||
directory = await asyncio.wait_for(reader.list_pages(base_id=base["id"], include_content=False), timeout=1)
|
||||
detail = await asyncio.wait_for(reader.get_page("wiki/ready", base_id=base["id"]), timeout=1)
|
||||
sources = await asyncio.wait_for(reader.list_sources(base_id=base["id"]), timeout=1)
|
||||
jobs = await asyncio.wait_for(reader.list_jobs(base_id=base["id"]), timeout=1)
|
||||
|
||||
assert [row["slug"] for row in directory] == ["wiki/ready"]
|
||||
assert detail is not None and detail["content_markdown"] == "上次成功导入的正文"
|
||||
assert len(sources) == 1
|
||||
assert any(job["status"] == "completed" for job in jobs)
|
||||
counters.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_bases_loads_all_statistics_in_one_statement(
|
||||
repository: AssistantKnowledgeRepository,
|
||||
|
||||
Reference in new issue
Block a user