Skip to content

[quality] test: unit coverage for scripts/generate_skill_index.py - #143

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-generate-skill-index
Open

[quality] test: unit coverage for scripts/generate_skill_index.py#143
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-generate-skill-index

Conversation

@kubestellar-hive

Copy link
Copy Markdown

Test Improvement

Adds tests/test_generate_skill_index.py — 33 unittest cases for scripts/generate_skill_index.py.

Claimed ground (files / functions)

  • New file: tests/test_generate_skill_index.py (only file touched)
  • Functions under test in scripts/generate_skill_index.py: find_skill_files, parse_front_matter, build_skill_entry, build_catalog, validate_catalog, render_markdown, main (--write / --check)
  • No production file is modified.

Why

The script is the only supported producer of docs/skills/index.json and index.md, but it had no direct unit tests. The only existing coverage is TestSkillCatalogUpToDate in tests/test_live_build_invariants.py, which shells out to --check and asserts freshness — it exercises none of the failure branches:

  • markdown with no YAML front matter
  • front matter that parses to a non-mapping
  • missing required front-matter keys
  • entry_point that disagrees with the file path
  • JSON Schema violations (validate_catalogSystemExit(1))
  • --check distinguishing a stale index.json from a stale index.md

Isolation

Tests patch REPO_ROOT, SKILLS_DIR, SCHEMA_PATH, INDEX_PATH to a tempfile tree (the real index.schema.json is copied in), so the repo catalog is never read or written. No network, no subprocess.

Result

$ pytest tests/test_generate_skill_index.py -q
33 passed

Full suite: 136 passed, 1 failed, 2 skipped — the single failure is the pre-existing TestSkillCatalogUpToDate daily staleness bug tracked in #137 (generated_at: date.today()), untouched by this PR.

Disjointness check

Compared against every open PR in this repo: #138 (tests/test_fisherman_install.py), #140 (dakota/src/, live/src, justfile, tests/test_live_build_invariants.py, tests/test_luks_unlock.py), #142 (justfile, live/Containerfile, scripts/verify-image-signature.sh), #124/#125/#126/#130 (.github/workflows/). None touches scripts/generate_skill_index.py or tests/test_generate_skill_index.py.

Gate note

Unit tests only — no E2E gate applies; this PR changes no ISO/build path.


Filed by quality agent (hold-gated mode). Human review required. Do not merge without review; hold label must stay.

— hive: agent=quality backend=copilot model=claude-opus-5

Adds tests/test_generate_skill_index.py — 33 unittest cases covering
find_skill_files, parse_front_matter, build_skill_entry, build_catalog,
validate_catalog, render_markdown and the --write/--check paths of main().

The script had no direct unit tests. The only existing coverage was
TestSkillCatalogUpToDate in tests/test_live_build_invariants.py, which
shells out to --check and asserts freshness; it exercises none of the
error branches (missing front matter, non-mapping front matter, missing
required keys, entry_point/path mismatch, schema violations).

Tests run against a temporary docs/skills tree via patched module
constants, so the repo's real catalog is never read or written.

Assisted-by: Claude Opus 5 via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/test_generate_skill_index.py (371 lines, test-only) exercises real failure branches — missing/non-mapping front matter, missing required keys, entry_point mismatch, real JSON-Schema validation, --check staleness distinctions — against a temp fixture tree, not smoke tests. CI log confirms only the pre-existing skill-catalog failure, which is ironically the exact bug class this suite documents.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Work is intentionally paused.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant