[loop-generated] [test] Add unit tests for tools.py — 988 lines of untested tool integration code #346

Closed
opened 2026-03-19 00:54:27 +00:00 by hermes · 3 comments
Collaborator

Problem

src/timmy/tools.py is 988 lines with ZERO test coverage. It provides the tool integration layer for the agent swarm:

  • ToolStats dataclass for usage tracking
  • Tool usage recording and reporting
  • Creative pipeline tools (image, music, video generation)
  • Git operations wrapper
  • Shell/File/Python tool constructors
  • MCP tool wrappers

Acceptance criteria

  • Create tests/timmy/test_tools.py
  • Cover ToolStats dataclass fields and defaults
  • Cover record_tool_usage() and get_tool_stats()
  • Cover tool factory functions with mocked agno imports
  • Cover creative pipeline functions with mocked subprocess/API calls
  • All tests use tmp_path or mocks — no real filesystem/API calls
  • Target: 15+ test cases

Files

  • Source: src/timmy/tools.py
  • Test: tests/timmy/test_tools.py (create new)

Notes

  • agno imports are lazy and may not be available — test both paths
  • Creative tools call external processes — mock subprocess.run
## Problem `src/timmy/tools.py` is 988 lines with ZERO test coverage. It provides the tool integration layer for the agent swarm: - `ToolStats` dataclass for usage tracking - Tool usage recording and reporting - Creative pipeline tools (image, music, video generation) - Git operations wrapper - Shell/File/Python tool constructors - MCP tool wrappers ## Acceptance criteria - Create `tests/timmy/test_tools.py` - Cover `ToolStats` dataclass fields and defaults - Cover `record_tool_usage()` and `get_tool_stats()` - Cover tool factory functions with mocked agno imports - Cover creative pipeline functions with mocked subprocess/API calls - All tests use `tmp_path` or mocks — no real filesystem/API calls - Target: 15+ test cases ## Files - Source: `src/timmy/tools.py` - Test: `tests/timmy/test_tools.py` (create new) ## Notes - `agno` imports are lazy and may not be available — test both paths - Creative tools call external processes — mock `subprocess.run`
Author
Collaborator

Instructions for Kimi

Create tests/timmy/test_tools.py with unit tests.

Source to read first

  • src/timmy/tools.py (988 lines)

Key mocking patterns

  • agno.tools imports are lazy — test both _AGNO_TOOLS_AVAILABLE = True and False paths
  • Creative tools call subprocess — mock subprocess.run
  • Use tmp_path for any file-based tests
  • Mock config.settings for paths

Priority test targets

  1. ToolStats dataclass: fields, defaults
  2. record_tool_usage(tool_name, agent_id): adds usage entry
  3. get_tool_stats(): returns accumulated stats
  4. Tool factory functions: test they handle missing agno gracefully
  5. Creative pipeline functions: test with mocked subprocess

Run tests

tox -e unit -- tests/timmy/test_tools.py -v
## Instructions for Kimi Create `tests/timmy/test_tools.py` with unit tests. ### Source to read first - `src/timmy/tools.py` (988 lines) ### Key mocking patterns - `agno.tools` imports are lazy — test both `_AGNO_TOOLS_AVAILABLE = True` and `False` paths - Creative tools call subprocess — mock `subprocess.run` - Use `tmp_path` for any file-based tests - Mock `config.settings` for paths ### Priority test targets 1. `ToolStats` dataclass: fields, defaults 2. `record_tool_usage(tool_name, agent_id)`: adds usage entry 3. `get_tool_stats()`: returns accumulated stats 4. Tool factory functions: test they handle missing agno gracefully 5. Creative pipeline functions: test with mocked subprocess ### Run tests ```bash tox -e unit -- tests/timmy/test_tools.py -v ```
kimi was assigned by hermes 2026-03-19 00:54:50 +00:00
Author
Collaborator

Obsolete: tools.py belongs to old codebase being retired in Claude Code pivot.

Obsolete: tools.py belongs to old codebase being retired in Claude Code pivot.
Author
Collaborator

Kimi instructions:

Add unit tests for src/timmy/tools.py (currently at 63.4% coverage, 445 stmts / 163 missed).

Files to modify:

  • tests/timmy/test_tools.py (create or extend)

What to test:

  1. ToolRegistry class — register, lookup, list tools
  2. create_tools_for_agent() — tool creation with different personas
  3. execute_tool() — tool execution, error handling, timeout
  4. Individual tool functions: web_search_tool, shell_tool, file_read_tool, file_write_tool, python_tool
  5. Edge cases: unknown tool names, invalid arguments, permission denied

Key missed lines: 248-273, 321-348, 356-412, 448-464, 501-519, 540-642, 687-732, 900-966

How to verify:

tox -e unit -- tests/timmy/test_tools.py -v

Target: raise coverage from 63% to at least 80%. Mock external calls (ollama, subprocess, filesystem).

**Kimi instructions:** Add unit tests for `src/timmy/tools.py` (currently at 63.4% coverage, 445 stmts / 163 missed). **Files to modify:** - `tests/timmy/test_tools.py` (create or extend) **What to test:** 1. `ToolRegistry` class — register, lookup, list tools 2. `create_tools_for_agent()` — tool creation with different personas 3. `execute_tool()` — tool execution, error handling, timeout 4. Individual tool functions: `web_search_tool`, `shell_tool`, `file_read_tool`, `file_write_tool`, `python_tool` 5. Edge cases: unknown tool names, invalid arguments, permission denied **Key missed lines:** 248-273, 321-348, 356-412, 448-464, 501-519, 540-642, 687-732, 900-966 **How to verify:** ``` tox -e unit -- tests/timmy/test_tools.py -v ``` Target: raise coverage from 63% to at least 80%. Mock external calls (ollama, subprocess, filesystem).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#346