Skip to content

test(cli): comprehensive test suite for manus-agent osv subcommand + README docs - #120

Open
manus-use wants to merge 1 commit into
mainfrom
feat/cli-osv-tests
Open

test(cli): comprehensive test suite for manus-agent osv subcommand + README docs#120
manus-use wants to merge 1 commit into
mainfrom
feat/cli-osv-tests

Conversation

@manus-use

Copy link
Copy Markdown
Owner

test(cli): comprehensive test suite for manus-agent osv CLI subcommand

What this PR does

The osv subcommand was introduced in merged PR #97 (feat(tools): OSV.dev affected-package resolver — get_osv_data tool + manus-agent osv CLI) but had zero CLI-level test coverage.

The fetch_osv_data() function itself is tested in test_osv_data.py (408 lines / 32 tests), but three things were completely untested:

  • _build_osv_parser() — argparse setup for the osv subcommand
  • _run_osv() — all output branches (text / JSON / not-found / error / edge cases)
  • main() dispatch — routing when argv[0] is "osv"

Additionally, manus-agent osv was not documented in README.md. The subcommand shipped and worked but had no entry in the CLI reference or table of contents.

Changes

tests/test_cli_osv.py — 51 new tests across 6 suites

Suite Tests What is covered
TestBuildOsvParser 10 prog string, required CVE-ID positional, --output default/choices/rejection, help text, description content
TestRunOsvJsonOutput 7 found/not-found/error payloads → valid JSON; records, aliases, affected_ecosystems present
TestRunOsvTextOutput 14 message printed; aliases, record IDs, package ecosystem:name, introduced/fixed versions, severity; (no fixed version listed) placeholder; Last affected line; empty aliases suppressed; empty packages skips record block; empty severity score suppressed; multiple records all printed; introduced defaults to "0" when empty
TestRunOsvErrors 6 error payload text + JSON; missing CVE-ID exits nonzero; invalid --output exits nonzero; CVE-ID forwarded to fetch_osv_data; whitespace stripped
TestSubcommandsRegistry 3 "osv" in _SUBCOMMANDS; is a set; no duplicate
TestMainDispatchOsv 5 main() routes osv; --output json forwarded; not-found exits 0; does not fall through to single-shot; fetch_osv_data called with correct CVE-ID
TestRunOsvImportPath 4 fetch_osv_data importable; _run_osv returns int; returns 0 on text/json success

README.md

  • Added manus-agent osv <CVE-ID> section between poc-search and blast-radius
  • Added TOC entry [osv](#manus-agent-osv-cve-id--osvdev-package-level-version-ranges)

Test results

1209 passed, 3 deselected, 3 warnings in 24.50s

(1158 baseline + 51 new; zero failures)

Existing open PRs checked against — no overlap

This PR adds test coverage and docs for an already-merged feature (PR #97). It does not implement any new tool or CLI subcommand, so there is no overlap with any existing open PR.

Open PRs verified as non-overlapping:
#51, #53, #54, #58, #60, #64, #65, #67, #74, #75, #76, #77, #78, #79, #80, #82, #83, #85, #86, #87, #88, #89, #90, #96, #98, #100, #103, #104, #105, #106, #107, #108, #109, #110, #111, #112, #113, #114, #115, #116, #117, #118, #119

None of those PRs add tests for _run_osv or _build_osv_parser.

The `osv` subcommand was merged in PR #97 but had zero CLI-level test
coverage.  The fetch_osv_data() function itself is tested in
test_osv_data.py (408 lines), but _build_osv_parser(), _run_osv(), and
the main() dispatch path for "osv" were completely untested.

This PR adds tests/test_cli_osv.py with 51 tests across 6 suites:

- TestBuildOsvParser (10): prog string, required positional CVE-ID,
  output flag defaults/choices (text/json), invalid choice rejection,
  --help output, description mentions OSV/CVE.
- TestRunOsvJsonOutput (7): found/not-found/error payloads produce
  valid JSON; records, aliases, affected_ecosystems present in output.
- TestRunOsvTextOutput (14): not-found message printed; found message
  with aliases, OSV record IDs, package ecosystem:name, introduced/
  fixed versions, severity; no-fix placeholder "(no fixed version
  listed)"; last_affected shown; empty aliases suppressed; empty
  packages skips record block; empty severity score suppressed;
  multiple records all printed; introduced defaults to "0" when empty.
- TestRunOsvErrors (6): error payload prints message; error payload
  JSON still valid; missing CVE-ID exits nonzero; invalid output choice
  exits nonzero; CVE-ID passed to fetch_osv_data unchanged; whitespace
  stripped before dispatch.
- TestSubcommandsRegistry (3): "osv" in _SUBCOMMANDS, is a set, no dup.
- TestMainDispatchOsv (5): main() routes osv subcommand; JSON flag
  forwarded; not-found exits zero; does not route to single-shot;
  fetch_osv_data called with correct CVE-ID.
- TestRunOsvImportPath (4): fetch_osv_data importable; rc is int;
  returns 0 for text and json success paths.

Also adds `manus-agent osv` to README.md (section + TOC entry):
the subcommand was shipping but completely undocumented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant