diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-25 18:24:51 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-25 18:24:51 +0200 |
| commit | 3e61d483675c486ebbf3ade30562b1ca94f4bb46 (patch) | |
| tree | cee9d841a88f323f1fcf28ba043bce034149110d /test_llamachat.py | |
| parent | 0619b09fa02815ad33632c8ba41f34601367cdd3 (diff) | |
| download | llamachat-3e61d483675c486ebbf3ade30562b1ca94f4bb46.tar.gz llamachat-3e61d483675c486ebbf3ade30562b1ca94f4bb46.zip | |
test: use generic skill names in fixtures
Diffstat (limited to 'test_llamachat.py')
| -rwxr-xr-x | test_llamachat.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/test_llamachat.py b/test_llamachat.py index 0c7d2d0..ebb90ce 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -56,18 +56,18 @@ ngl = all """ SKILLS_SAMPLE = { - "firefly-cli/SKILL.md": ( + "finance-cli/SKILL.md": ( "---\n" - "name: firefly-cli\n" - "description: Operate a Firefly III instance from the command line.\n" + "name: finance-cli\n" + "description: Operate a finance CLI from the command line.\n" "---\n" "\n" - "# firefly-cli\n" - "Run `firefly auth test` first.\n" + "# finance-cli\n" + "Run `finance auth test` first.\n" ), - "test-build-slackbuild/SKILL.md": ( + "build-helper/SKILL.md": ( "---\n" - "name: test-build-slackbuild\n" + "name: build-helper\n" "description: Drive the sbo-dockerbuild test-build tool.\n" "---\n" "\n" @@ -1140,9 +1140,9 @@ def test_config_defaults(): def test_skills_config(): with tempfile.TemporaryDirectory() as tmp: skills_dir = Path(tmp) / "skills" - (skills_dir / "firefly-cli").mkdir(parents=True) - (skills_dir / "firefly-cli" / "SKILL.md").write_text( - "---\nname: firefly-cli\ndescription: d\n---\n\nbody\n" + (skills_dir / "finance-cli").mkdir(parents=True) + (skills_dir / "finance-cli" / "SKILL.md").write_text( + "---\nname: finance-cli\ndescription: d\n---\n\nbody\n" ) path = Path(tmp) / "config.toml" path.write_text(f'skills_enabled = true\nskills_dir = "{skills_dir}"\n') @@ -2763,7 +2763,7 @@ def _tool_round(query: str = "q"): ] -def _skill_round(name: str = "firefly-cli"): +def _skill_round(name: str = "finance-cli"): """One streamed round that asks to load a skill.""" return [ ( @@ -3292,7 +3292,7 @@ def test_skill_tool_round(): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) - _write_skills(root, {"firefly-cli/SKILL.md": SKILLS_SAMPLE["firefly-cli/SKILL.md"]}) + _write_skills(root, {"finance-cli/SKILL.md": SKILLS_SAMPLE["finance-cli/SKILL.md"]}) store = skills.SkillStore(root) client = backend.Client("http://x") @@ -3314,7 +3314,7 @@ def test_skill_tool_round(): )) # The load is reported and the answer flows through. - assert ("skill_loaded", "firefly-cli") in out, out + assert ("skill_loaded", "finance-cli") in out, out assert ("content", "answered") in out, out # The offered schema is the load_skill one; the final round has none. @@ -3330,8 +3330,8 @@ def test_skill_tool_round(): assert assistant["tool_calls"][0]["function"]["name"] == "load_skill" tool_msg = next(m for m in second if m["role"] == "tool") assert tool_msg["tool_call_id"] == "call_2" - assert "run `firefly auth test` first" in tool_msg["content"].lower() - assert "[skill: firefly-cli]" in tool_msg["content"] + assert "run `finance auth test` first" in tool_msg["content"].lower() + assert "[skill: finance-cli]" in tool_msg["content"] print("ok skill tool round") @@ -3340,13 +3340,13 @@ def test_skill_tool_errors(): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) - _write_skills(root, {"firefly-cli/SKILL.md": SKILLS_SAMPLE["firefly-cli/SKILL.md"]}) + _write_skills(root, {"finance-cli/SKILL.md": SKILLS_SAMPLE["finance-cli/SKILL.md"]}) store = skills.SkillStore(root) client = backend.Client("http://x") cfg = backend.SkillsConfig(enabled=True, store=store, max_searches=1) # Unknown skill name -> error tool message, no skill_loaded yield. - rounds = [_skill_round("vault-librarian"), [("content", "done")]] + rounds = [_skill_round("notes-keeper"), [("content", "done")]] seen = [] def scripted(model, messages, tools): @@ -3360,7 +3360,7 @@ def test_skill_tool_errors(): assert ("content", "done") in out, out assert not any(k == "skill_loaded" for k, _ in out), out tool_msg = next(m for m in seen[1] if m["role"] == "tool") - assert "No such skill: vault-librarian" in tool_msg["content"] + assert "No such skill: notes-keeper" in tool_msg["content"] # Malformed arguments are answered rather than left dangling. bad = {"id": "call_9", "name": "load_skill", "arguments": "{not json"} @@ -3399,7 +3399,7 @@ def test_skill_round_cap(): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) - _write_skills(root, {"firefly-cli/SKILL.md": SKILLS_SAMPLE["firefly-cli/SKILL.md"]}) + _write_skills(root, {"finance-cli/SKILL.md": SKILLS_SAMPLE["finance-cli/SKILL.md"]}) store = skills.SkillStore(root) client = backend.Client("http://x") @@ -3552,14 +3552,14 @@ def test_skills_store(): store = skills.SkillStore(root) assert store.names() == [ - "firefly-cli", "no-frontmatter", "test-build-slackbuild" + "build-helper", "finance-cli", "no-frontmatter" ] - skill = store.load("firefly-cli") + skill = store.load("finance-cli") assert skill is not None - assert skill.name == "firefly-cli" - assert skill.description == "Operate a Firefly III instance from the command line." - assert skill.text.startswith("# firefly-cli") + assert skill.name == "finance-cli" + assert skill.description == "Operate a finance CLI from the command line." + assert skill.text.startswith("# finance-cli") # A name that does not exist, and an absent directory, both yield None. assert store.load("nope") is None @@ -3570,11 +3570,11 @@ def test_skills_store(): assert function["name"] == "load_skill" assert function["parameters"]["required"] == ["name"] assert function["parameters"]["properties"]["name"]["enum"] == store.names() - assert "firefly-cli" in function["description"] + assert "finance-cli" in function["description"] directory = store.directory() - assert "firefly-cli" in directory - assert "test-build-slackbuild" in directory + assert "finance-cli" in directory + assert "build-helper" in directory print("ok skills store") @@ -3583,13 +3583,13 @@ def test_skills_mentions(): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) - _write_skills(root, {"firefly-cli/SKILL.md": SKILLS_SAMPLE["firefly-cli/SKILL.md"]}) + _write_skills(root, {"finance-cli/SKILL.md": SKILLS_SAMPLE["finance-cli/SKILL.md"]}) store = skills.SkillStore(root) - assert store.match_mentions("use firefly-cli for this") == ["firefly-cli"] - assert store.match_mentions("USE FIREFLY-CLI now") == ["firefly-cli"] + assert store.match_mentions("use finance-cli for this") == ["finance-cli"] + assert store.match_mentions("USE FINANCE-CLI now") == ["finance-cli"] # No word boundary, no mention: a substring must not load a skill. - assert store.match_mentions("firefly-cli2 rocks") == [] + assert store.match_mentions("finance-cli2 rocks") == [] assert store.match_mentions("the fireflies are out") == [] assert store.match_mentions("nothing here") == [] print("ok skills mentions") @@ -3598,11 +3598,11 @@ def test_skills_mentions(): def test_skills_parse_commands(): from llamachat import skills - known = {"firefly-cli", "handoff"} + known = {"finance-cli", "handoff"} text, loaded = skills.parse_commands( - "/firefly-cli fix my budget /unknown stays", known + "/finance-cli fix my budget /unknown stays", known ) - assert loaded == ["firefly-cli"] + assert loaded == ["finance-cli"] assert text == "fix my budget /unknown stays" text, loaded = skills.parse_commands("no commands here", known) @@ -3624,11 +3624,11 @@ def test_skills_parse_commands(): def test_skill_tool_message(): from llamachat import skills - skill = skills.Skill(name="firefly-cli", description="d", text="body text") + skill = skills.Skill(name="finance-cli", description="d", text="body text") msg = skills.tool_message("call_1", skill) assert msg["role"] == "tool" assert msg["tool_call_id"] == "call_1" - assert "[skill: firefly-cli]" in msg["content"] + assert "[skill: finance-cli]" in msg["content"] assert "body text" in msg["content"] err = skills.tool_message("call_1", None, error="No such skill") @@ -3637,7 +3637,7 @@ def test_skill_tool_message(): last = skills.tool_message("call_1", skill, last=True) assert skills.NO_MORE_TOOLS in last["content"] - assert skills.parse_name('{"name": "firefly-cli"}') == "firefly-cli" + assert skills.parse_name('{"name": "finance-cli"}') == "finance-cli" assert skills.parse_name("not json") == "" assert skills.parse_name('{"query": "x"}') == "" assert skills.parse_name("") == "" @@ -3648,9 +3648,9 @@ def test_skills_db(): with tempfile.TemporaryDirectory() as tmp: history = db.History(Path(tmp) / "history.db") sid = history.create_session("chat", "m") - history.set_skills(sid, ["firefly-cli", "handoff"]) + history.set_skills(sid, ["finance-cli", "handoff"]) session = history.get_session(sid) - assert json.loads(session["skills"]) == ["firefly-cli", "handoff"] + assert json.loads(session["skills"]) == ["finance-cli", "handoff"] history.set_skills(sid, []) assert json.loads(history.get_session(sid)["skills"]) == [] @@ -3679,8 +3679,8 @@ def test_skills_column_migration(): history = db.History(path) sid = history.create_session("chat", "m") - history.set_skills(sid, ["firefly-cli"]) - assert json.loads(history.get_session(sid)["skills"]) == ["firefly-cli"] + history.set_skills(sid, ["finance-cli"]) + assert json.loads(history.get_session(sid)["skills"]) == ["finance-cli"] print("ok skills column migration") |
