test(skills): verify source identity across public API and browser

This commit is contained in:
Xubin Ren committed 2026-11-06 00:26:32 +08:00
1 parent 70eca8343b
commit 112ea9d174
5 files changed
+132 -7

No files matched your search

+4
View File
@@ -524,6 +524,10 @@ async def test_install_skillhub_skill_checks_fingerprint_and_extracts_safely(
"version": "1.1.8",
}
assert (tmp_path / "skills" / "ima-skills" / "SKILL.md").read_bytes() == skill_content
assert json.loads((tmp_path / "skills" / "ima-skills" / ".nanobot-origin.json").read_text()) == {
"provider": "skillhub", "source": "", "skill_id": "ima-skills",
}
assert (await install_marketplace_skill("", "ima-skills", tmp_path, provider="skillhub"))["already_installed"]
@pytest.mark.parametrize(
@@ -197,3 +197,19 @@ async def test_two_installers_cannot_replace_the_winning_source(
rows = (await search_marketplace_skills(NAME, tmp_path))["skills"]
winner = next(row for row in rows if row["installed"])
assert (tmp_path / "skills" / NAME / "SKILL.md").read_text() == winner["source"]
@pytest.mark.asyncio
async def test_receipt_write_failure_leaves_no_partial_install_and_retry_works(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, installer: list[Path], catalog: None,
) -> None:
with monkeypatch.context() as failure:
def fail_write(*_args: object) -> None:
raise OSError("disk full")
failure.setattr("nanobot.webui.skills_marketplace.atomic_write_text", fail_write)
with pytest.raises(OSError, match="disk full"):
await install_marketplace_skill(SOURCE, NAME, tmp_path)
assert list((tmp_path / "skills").iterdir()) == []
assert all(not row["installed"] for row in (await search_marketplace_skills(NAME, tmp_path))["skills"])
assert (await install_marketplace_skill(SOURCE, NAME, tmp_path))["installed"]