diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-25 18:15:12 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-25 18:15:12 +0200 |
| commit | 6cd0b8b71e86acfa236969599b012d19c33fe167 (patch) | |
| tree | 4b764d0e08768d91a0fe487c56a685f9f5c318e3 /test_llamachat.py | |
| parent | 88ac15f496cde6104709ec6925212df0eb3cddc2 (diff) | |
| download | llamachat-6cd0b8b71e86acfa236969599b012d19c33fe167.tar.gz llamachat-6cd0b8b71e86acfa236969599b012d19c33fe167.zip | |
feat: persist loaded skills per session
Diffstat (limited to 'test_llamachat.py')
| -rwxr-xr-x | test_llamachat.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test_llamachat.py b/test_llamachat.py index ed990af..81a430b 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -3486,6 +3486,46 @@ def test_skill_tool_message(): print("ok skill tool message") +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"]) + session = history.get_session(sid) + assert json.loads(session["skills"]) == ["firefly-cli", "handoff"] + + history.set_skills(sid, []) + assert json.loads(history.get_session(sid)["skills"]) == [] + + # A fresh session has no skills stored. + sid2 = history.create_session("oneshot", "m") + assert history.get_session(sid2)["skills"] == "" + print("ok skills db") + + +def test_skills_column_migration(): + # A database created before the column existed gains it on open. + import sqlite3 as _sqlite3 + + with tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) / "old.db" + conn = _sqlite3.connect(path) + conn.execute( + "CREATE TABLE sessions (id INTEGER PRIMARY KEY, mode TEXT NOT NULL," + " title TEXT, model TEXT, prompt_name TEXT NOT NULL DEFAULT ''," + " prompt_custom TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL," + " updated_at INTEGER NOT NULL)" + ) + conn.commit() + conn.close() + + 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"] + print("ok skills column migration") + + if __name__ == "__main__": test_presets() test_real_presets() @@ -3553,4 +3593,6 @@ if __name__ == "__main__": test_skills_mentions() test_skills_parse_commands() test_skill_tool_message() + test_skills_db() + test_skills_column_migration() print("\nall checks passed") |
