|
| 1 | +# ✅ Test Coverage Improvement Plan |
| 2 | + |
| 3 | +NOTE: Keep track of your work at the end of the file after "PROGRESS ON WORK." |
| 4 | +NOTE: The command to run coverage is: `uv run pytest --cov agent_memory_server --cov-report=term-missing --run-api-tests` |
| 5 | + |
| 6 | +## 🎯 Goal |
| 7 | +Increase total coverage from **51% to 75%** with minimal disruption and maximum impact. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 🔝 Priority Targets (Uncovered Critical Logic) |
| 12 | + |
| 13 | +### 1. `cli.py` (0%) |
| 14 | +- **Tests to write:** |
| 15 | + - `version`, `api`, `mcp`, `schedule_task`, `task_worker`, `migrate_memories`, `rebuild_index` |
| 16 | +- **Approach:** Use `click.testing.CliRunner`. Mock Redis and async functions. |
| 17 | + |
| 18 | +### 2. `long_term_memory.py` (46%) |
| 19 | +- **Tests to write:** |
| 20 | + - `promote_working_memory_to_long_term`, `index_long_term_memories`, `search_memories` |
| 21 | +- **Approach:** Parametrize edge cases (no matches, Redis down, invalid filter). Mock Redis and vector indexing. |
| 22 | + |
| 23 | +### 3. `summarization.py` (14%) |
| 24 | +- **Tests to write:** |
| 25 | + - `_incremental_summary`, edge cases for token limits and empty input |
| 26 | +- **Approach:** Mock LLM client. Use short token windows to force edge behavior. |
| 27 | + |
| 28 | +### 4. `docket_tasks.py` (0%) |
| 29 | +- **Tests to write:** |
| 30 | + - Task registration, task collection membership, verify Redis URL use |
| 31 | +- **Approach:** Mock Docket client, test task registration logic |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## ⚙️ Medium-Priority |
| 36 | + |
| 37 | +### 5. `filters.py` (51%) |
| 38 | +- **Tests to write:** |
| 39 | + - Each filter type (`eq`, `gt`, `between`, etc.) |
| 40 | +- **Approach:** Use parametric testing, validate Redis query expressions |
| 41 | + |
| 42 | +### 6. `llms.py` (66%) |
| 43 | +- **Tests to write:** |
| 44 | + - Model selection logic, token limit behaviors, prompt formatting |
| 45 | +- **Approach:** Mock OpenAI and Anthropic clients |
| 46 | + |
| 47 | +### 7. `mcp.py` (66%) |
| 48 | +- **Tests to write:** |
| 49 | + - Tool interface dispatch, SSE vs stdio routing |
| 50 | +- **Approach:** Patch `run_stdio_async`, `run_sse_async`, assert logs and Redis effects |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## 🧹 Low-Hanging Fruit (Fast Wins) |
| 55 | + |
| 56 | +### 8. `utils/api_keys.py` (0%) |
| 57 | +- **Add tests for:** key parsing, fallback logic |
| 58 | + |
| 59 | +### 9. `logging.py` (50%) |
| 60 | +- **Add tests for:** `configure_logging`, custom level configs |
| 61 | + |
| 62 | +### 10. `dependencies.py` (92%) |
| 63 | +- **Add tests for:** `add_task` fallback path (no Docket) |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## 🧪 Integration Tests |
| 68 | + |
| 69 | +- Test full flow: |
| 70 | + - POST to `working_memory` → promotion task triggers → data lands in `long_term_memory` |
| 71 | + - GET from memory search endpoint returns expected result |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## 🗂️ Progress Tracking Template |
| 76 | + |
| 77 | +| File | Coverage Before | Target | Status | |
| 78 | +|------|------------------|--------|--------| |
| 79 | +| `cli.py` | 0% | 80%+ | ⬜️ | |
| 80 | +| `long_term_memory.py` | 46% | 70%+ | ⬜️ | |
| 81 | +| `summarization.py` | 14% | 60%+ | ⬜️ | |
| 82 | +| `filters.py` | 51% | 75% | ⬜️ | |
| 83 | +| `llms.py` | 66% | 80% | ⬜️ | |
| 84 | +| `docket_tasks.py` | 0% | 80% | ⬜️ | |
| 85 | +| `mcp.py` | 66% | 85% | ⬜️ | |
| 86 | +| `api_keys.py` | 0% | 100% | ⬜️ | |
| 87 | +| `logging.py` | 50% | 100% | ⬜️ | |
| 88 | +| `dependencies.py` | 92% | 100% | ⬜️ | |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 🧰 Tools & Tips |
| 93 | + |
| 94 | +- Use `pytest-cov` with `--cov-report=term-missing` |
| 95 | +- Use `pytest --durations=10` to find slow tests |
| 96 | +- Group new tests by file in `tests/unit` or `tests/integration` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## 📈 Exit Criteria |
| 101 | + |
| 102 | +- At least **75%** overall test coverage |
| 103 | +- 80%+ coverage on top priority files |
| 104 | +- All major logic paths exercised with mocks or real integration |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## PROGRESS ON WORK |
0 commit comments