docs: label test file and add TEST_EXPENSES_AGENT.md

Adds module-level label and cross-reference to the new doc.
TEST_EXPENSES_AGENT.md documents every test group, case, and the
real-world bug each test guards against (e.g. In-N-Out OCR mismatch).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-16 18:35:07 -04:00
parent 469025b6f2
commit 9f38fb013c
2 changed files with 213 additions and 7 deletions

View File

@@ -1,12 +1,31 @@
"""
Unit tests for ExpensesAgent logic.
ActiveBlue AI — Expenses Agent Unit Tests
==========================================
Suite: test_expenses_agent.py
Module: agent_service/agents/expenses_agent.py
agent_service/tools/receipt_parser.py
addons/activeblue_ai/models/ab_ai_mail.py
Covers:
- _find_semantic_duplicate (two-pass dedup algorithm)
- _plan() (keyword detection → user_confirmed, user_dup_decision)
- _act() confirmation gate (enters awaiting_confirmation before writing records)
- parse_upload (ZIP extraction, filename date parsing)
- _text_to_html (HTML escaping and newline conversion)
Purpose
-------
Verify the core business logic of the expenses agent without requiring
a live Odoo instance, database, or LLM. All external dependencies
(ORM, HTTP, Ollama) are mocked. Tests run in < 1 second.
Run
---
source .venv-test/bin/activate
python -m pytest tests/test_expenses_agent.py -v
Test groups
-----------
TestFindSemanticDuplicate — two-pass duplicate-detection algorithm
test_plan_* — intent keyword → user_confirmed / user_dup_decision
test_act_* — _act() confirmation gate and expense creation
TestParseUpload — receipt_parser ZIP handling and metadata
TestTextToHtml — HTML escaping (skipped without Odoo env)
See tests/TEST_EXPENSES_AGENT.md for full documentation.
"""
from __future__ import annotations