Skip to content

Add CLI test coverage (cli.py has zero tests) #16

@roeimichael

Description

@roeimichael

Problem

cli.py is the largest file in the project at 1105 lines and has zero test coverage. The install and uninstall commands modify Claude Code's settings.json. The status, anomalies, health commands all have logic that could break silently. New contributors modifying CLI behavior have no regression safety net.

What to do

Create tests/test_cli.py with at least:

  1. install command — verify hooks are written to the correct location
  2. uninstall command — verify hook entries are removed from settings.json
  3. status command — with mocked HTTP responses
  4. health command — with mocked HTTP responses
  5. config show (if implemented) — verify output includes all config sections

Recommended approach

  • Use typer.testing.CliRunner for invoking commands
  • Use tmp_path fixtures for filesystem operations
  • Use respx or unittest.mock.patch to mock httpx calls to the collector

Files to look at

  • src/context_analyzer_tool/cli.py — the module under test
  • tests/test_config.py — good example of how existing tests are structured

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliCLI commands and optionsarea: testsTest coverage and qualitydifficulty: intermediateRequires some familiarity with the codebaseenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions