mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-13 21:27:41 +02:00
[eric] marketplace: Get on every card and sheet, spinner, then Open; installs remembered by the backend and Open launches the app, workflow or skill
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9zwUaHucUgrdxvK8FvjYT
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
2afbdc5b05
commit
bc1e7acac9
@@ -0,0 +1,31 @@
|
||||
"""The store must remember what it installed across restarts, and survive a bad file."""
|
||||
|
||||
import json
|
||||
|
||||
from backend.apps.marketplace.installs import InstallRecord, load_installs, record_install
|
||||
|
||||
|
||||
def test_a_recorded_install_round_trips(tmp_path):
|
||||
p = str(tmp_path / "installs.json")
|
||||
record_install(InstallRecord(listing_id="git-graph", root_type="app", output_id="out-1", version="1.0.0"), p)
|
||||
record_install(InstallRecord(listing_id="hello", root_type="skill", skill_id="sk-1", version="1.0.0"), p)
|
||||
got = load_installs(p)
|
||||
assert set(got) == {"git-graph", "hello"}
|
||||
assert got["git-graph"].output_id == "out-1" and got["git-graph"].installed_at > 0
|
||||
|
||||
|
||||
def test_reinstalling_replaces_the_record_for_that_listing(tmp_path):
|
||||
p = str(tmp_path / "installs.json")
|
||||
record_install(InstallRecord(listing_id="git-graph", root_type="app", output_id="out-1", version="1.0.0"), p)
|
||||
record_install(InstallRecord(listing_id="git-graph", root_type="app", output_id="out-2", version="1.1.0"), p)
|
||||
got = load_installs(p)
|
||||
assert len(got) == 1 and got["git-graph"].output_id == "out-2" and got["git-graph"].version == "1.1.0"
|
||||
|
||||
|
||||
def test_a_missing_or_corrupt_file_reads_as_nothing_installed(tmp_path):
|
||||
p = str(tmp_path / "installs.json")
|
||||
assert load_installs(p) == {}
|
||||
(tmp_path / "installs.json").write_text("{not json")
|
||||
assert load_installs(p) == {}
|
||||
(tmp_path / "installs.json").write_text(json.dumps({"x": {"listing_id": "x"}}))
|
||||
assert load_installs(p) == {}
|
||||
Reference in New Issue
Block a user