Add unit test coverage for pure helpers in ai.py #55

Open
opened 2026-04-07 05:26:13 +00:00 by archeious · 0 comments
Owner

ai.py is documented as exempt from unit testing because it requires a live Anthropic API. But several helpers in ai.py are pure functions that have nothing to do with the API and could be tested without any mocking:

  • _filter_dir_tools(survey)ai.py:824 — tool list filtering by survey confidence
  • _format_survey_block(survey)ai.py:803 — survey dict → text block
  • _format_survey_signals(signals)ai.py:1021 — signals dict → text block
  • _default_survey()ai.py:784 — synthetic skip survey
  • _should_skip_dir(name)ai.py:80 — skip-list matching including *.egg-info glob
  • _path_is_safe(path, target)ai.py:69 — path containment check
  • _block_to_dict(block)ai.py:1007 — SDK block → plain dict

Fix

  • Add tests/test_ai_pure.py covering these helpers
  • Update the test coverage table in DevelopmentGuide.mdai.py is no longer fully exempt, only the API-dependent parts are
  • Update the exempt-modules list in CLAUDE.md

Notes

  • Discovered during Session 5 documentation deep dive (#53)
  • _filter_dir_tools in particular has nontrivial branching (confidence threshold, protected tools, missing survey) and is the kind of thing that will silently break
  • Low priority; not blocking Phase 3
`ai.py` is documented as exempt from unit testing because it requires a live Anthropic API. But several helpers in `ai.py` are pure functions that have nothing to do with the API and could be tested without any mocking: - `_filter_dir_tools(survey)` — `ai.py:824` — tool list filtering by survey confidence - `_format_survey_block(survey)` — `ai.py:803` — survey dict → text block - `_format_survey_signals(signals)` — `ai.py:1021` — signals dict → text block - `_default_survey()` — `ai.py:784` — synthetic skip survey - `_should_skip_dir(name)` — `ai.py:80` — skip-list matching including `*.egg-info` glob - `_path_is_safe(path, target)` — `ai.py:69` — path containment check - `_block_to_dict(block)` — `ai.py:1007` — SDK block → plain dict ## Fix - Add `tests/test_ai_pure.py` covering these helpers - Update the test coverage table in `DevelopmentGuide.md` — `ai.py` is no longer fully exempt, only the API-dependent parts are - Update the exempt-modules list in `CLAUDE.md` ## Notes - Discovered during Session 5 documentation deep dive (#53) - `_filter_dir_tools` in particular has nontrivial branching (confidence threshold, protected tools, missing survey) and is the kind of thing that will silently break - Low priority; not blocking Phase 3
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: archeious/luminos#55
No description provided.