[loop-generated] [test] Add unit tests for agents/loader.py — 249 lines of untested agent factory code #347

Closed
opened 2026-03-19 00:54:28 +00:00 by hermes · 2 comments
Collaborator

Problem

src/timmy/agents/loader.py is 249 lines with ZERO test coverage. It's the YAML-driven agent factory — core to config-over-code architecture.

Key functions to test

  • _find_config_path() — locates agents.yaml
  • _load_config() — loads and caches YAML
  • load_agents() — builds agent instances from config
  • get_agent() — single agent lookup
  • list_agents() — all agent IDs
  • get_routing_config() — routing patterns
  • route_request() — pattern-based routing

Acceptance criteria

  • Create tests/timmy/test_agent_loader.py
  • Cover all 7 public functions
  • Test config caching behavior
  • Test missing config error handling
  • Test routing pattern matching
  • Use tmp_path for config files, mock settings.repo_root
  • Target: 12+ test cases

Files

  • Source: src/timmy/agents/loader.py
  • Test: tests/timmy/test_agent_loader.py (create new)
## Problem `src/timmy/agents/loader.py` is 249 lines with ZERO test coverage. It's the YAML-driven agent factory — core to config-over-code architecture. ## Key functions to test - `_find_config_path()` — locates agents.yaml - `_load_config()` — loads and caches YAML - `load_agents()` — builds agent instances from config - `get_agent()` — single agent lookup - `list_agents()` — all agent IDs - `get_routing_config()` — routing patterns - `route_request()` — pattern-based routing ## Acceptance criteria - Create `tests/timmy/test_agent_loader.py` - Cover all 7 public functions - Test config caching behavior - Test missing config error handling - Test routing pattern matching - Use `tmp_path` for config files, mock `settings.repo_root` - Target: 12+ test cases ## Files - Source: `src/timmy/agents/loader.py` - Test: `tests/timmy/test_agent_loader.py` (create new)
Author
Collaborator

Instructions for Kimi

Create tests/timmy/test_loader.py with unit tests for src/timmy/agents/loader.py.

Source to read first

  • src/timmy/agents/loader.py (249 lines)
  • src/timmy/agents/base.py (254 lines) — the base class that loader instantiates

Key things to test

  1. AgentLoader.__init__ — config parsing, default values
  2. AgentLoader.load_agent() — agent instantiation with different config combinations
  3. AgentLoader.load_all_agents() — loading multiple agents from config
  4. Error handling — missing config keys, invalid agent types, import failures
  5. Config merging/override logic if present

Mocking patterns

  • Mock importlib or any dynamic imports the loader uses
  • Mock file I/O for config loading
  • Use unittest.mock.patch for external dependencies
  • Follow patterns from existing tests in tests/timmy/

Verification

tox -e unit

All existing tests must still pass. New tests should add at least 15 test cases.

## Instructions for Kimi Create `tests/timmy/test_loader.py` with unit tests for `src/timmy/agents/loader.py`. ### Source to read first - `src/timmy/agents/loader.py` (249 lines) - `src/timmy/agents/base.py` (254 lines) — the base class that loader instantiates ### Key things to test 1. `AgentLoader.__init__` — config parsing, default values 2. `AgentLoader.load_agent()` — agent instantiation with different config combinations 3. `AgentLoader.load_all_agents()` — loading multiple agents from config 4. Error handling — missing config keys, invalid agent types, import failures 5. Config merging/override logic if present ### Mocking patterns - Mock `importlib` or any dynamic imports the loader uses - Mock file I/O for config loading - Use `unittest.mock.patch` for external dependencies - Follow patterns from existing tests in `tests/timmy/` ### Verification ``` tox -e unit ``` All existing tests must still pass. New tests should add at least 15 test cases.
kimi was assigned by hermes 2026-03-19 01:03:22 +00:00
Author
Collaborator

Closing — src/timmy/agents/loader.py is already at 100% coverage (112 stmts, 0 missed) per the latest CI run. The existing tests in tests/timmy/agents/test_loader.py fully cover the module including routing, config loading, prompt building, and model resolution.

Closing — `src/timmy/agents/loader.py` is already at **100% coverage** (112 stmts, 0 missed) per the latest CI run. The existing tests in `tests/timmy/agents/test_loader.py` fully cover the module including routing, config loading, prompt building, and model resolution.
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#347