Initial import of NousResearch/hermes-agent
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
"""Tests for the todo tool module."""
|
||||
|
||||
import json
|
||||
|
||||
from tools.todo_tool import TodoStore, todo_tool
|
||||
|
||||
|
||||
class TestWriteAndRead:
|
||||
def test_write_replaces_list(self):
|
||||
store = TodoStore()
|
||||
items = [
|
||||
{"id": "1", "content": "First task", "status": "pending"},
|
||||
{"id": "2", "content": "Second task", "status": "in_progress"},
|
||||
]
|
||||
result = store.write(items)
|
||||
assert len(result) == 2
|
||||
assert result[0]["id"] == "1"
|
||||
assert result[1]["status"] == "in_progress"
|
||||
|
||||
def test_read_returns_copy(self):
|
||||
store = TodoStore()
|
||||
store.write([{"id": "1", "content": "Task", "status": "pending"}])
|
||||
items = store.read()
|
||||
items[0]["content"] = "MUTATED"
|
||||
assert store.read()[0]["content"] == "Task"
|
||||
|
||||
def test_write_deduplicates_duplicate_ids(self):
|
||||
store = TodoStore()
|
||||
result = store.write([
|
||||
{"id": "1", "content": "First version", "status": "pending"},
|
||||
{"id": "2", "content": "Other task", "status": "pending"},
|
||||
{"id": "1", "content": "Latest version", "status": "in_progress"},
|
||||
])
|
||||
assert result == [
|
||||
{"id": "2", "content": "Other task", "status": "pending"},
|
||||
{"id": "1", "content": "Latest version", "status": "in_progress"},
|
||||
]
|
||||
|
||||
|
||||
class TestHasItems:
|
||||
def test_empty_store(self):
|
||||
store = TodoStore()
|
||||
assert store.has_items() is False
|
||||
|
||||
def test_non_empty_store(self):
|
||||
store = TodoStore()
|
||||
store.write([{"id": "1", "content": "x", "status": "pending"}])
|
||||
assert store.has_items() is True
|
||||
|
||||
|
||||
class TestFormatForInjection:
|
||||
def test_empty_returns_none(self):
|
||||
store = TodoStore()
|
||||
assert store.format_for_injection() is None
|
||||
|
||||
def test_non_empty_has_markers(self):
|
||||
store = TodoStore()
|
||||
store.write([
|
||||
{"id": "1", "content": "Do thing", "status": "completed"},
|
||||
{"id": "2", "content": "Next", "status": "pending"},
|
||||
{"id": "3", "content": "Working", "status": "in_progress"},
|
||||
])
|
||||
text = store.format_for_injection()
|
||||
# Completed items are filtered out of injection
|
||||
assert "[x]" not in text
|
||||
assert "Do thing" not in text
|
||||
# Active items are included
|
||||
assert "[ ]" in text
|
||||
assert "[>]" in text
|
||||
assert "Next" in text
|
||||
assert "Working" in text
|
||||
assert "context compression" in text.lower()
|
||||
|
||||
|
||||
class TestMergeMode:
|
||||
def test_update_existing_by_id(self):
|
||||
store = TodoStore()
|
||||
store.write([
|
||||
{"id": "1", "content": "Original", "status": "pending"},
|
||||
])
|
||||
store.write(
|
||||
[{"id": "1", "status": "completed"}],
|
||||
merge=True,
|
||||
)
|
||||
items = store.read()
|
||||
assert len(items) == 1
|
||||
assert items[0]["status"] == "completed"
|
||||
assert items[0]["content"] == "Original"
|
||||
|
||||
def test_merge_appends_new(self):
|
||||
store = TodoStore()
|
||||
store.write([{"id": "1", "content": "First", "status": "pending"}])
|
||||
store.write(
|
||||
[{"id": "2", "content": "Second", "status": "pending"}],
|
||||
merge=True,
|
||||
)
|
||||
items = store.read()
|
||||
assert len(items) == 2
|
||||
|
||||
|
||||
class TestTodoToolFunction:
|
||||
def test_read_mode(self):
|
||||
store = TodoStore()
|
||||
store.write([{"id": "1", "content": "Task", "status": "pending"}])
|
||||
result = json.loads(todo_tool(store=store))
|
||||
assert result["summary"]["total"] == 1
|
||||
assert result["summary"]["pending"] == 1
|
||||
|
||||
def test_write_mode(self):
|
||||
store = TodoStore()
|
||||
result = json.loads(todo_tool(
|
||||
todos=[{"id": "1", "content": "New", "status": "in_progress"}],
|
||||
store=store,
|
||||
))
|
||||
assert result["summary"]["in_progress"] == 1
|
||||
|
||||
def test_no_store_returns_error(self):
|
||||
result = json.loads(todo_tool())
|
||||
assert "error" in result
|
||||
Reference in New Issue
Block a user