Repository navigation
Description
Description
Add unit tests and container integration tests for scripts/gh_issues.py, which currently has ~540 lines, ~15 functions, and zero test coverage. The script is deployed to downstream workspaces via the sync manifest and needs verification at both the logic and deployment layers.
Problem Statement
scripts/gh_issues.py was originally skipped for TDD with the rationale "no unit-testable logic beyond subprocess calls and rich rendering" (see #84). The script has since grown to include multiple pure-logic functions that are fully testable without mocking gh CLI calls or Rich rendering. Additionally, there is no verification that the deployed copy works inside the container or that runtime dependencies are available.
Proposed Solution
Two test layers:
1. Unit tests (tests/test_gh_issues.py)
Test all pure-logic functions — no subprocess mocking, no Rich rendering tests:
| Function | What it does |
|---|---|
_styled(value, style) |
Wraps text in Rich markup |
_extract_label(labels, prefix) |
Finds label by prefix, applies style |
_extract_type(labels) |
Finds type label, applies style |
_extract_scope(labels) |
Collects area:* labels |
_clean_title(title) |
Strips [FEATURE] etc. prefix |
_format_assignees(assignees) |
Formats assignee list |
_infer_review(pr) |
Derives review state from PR dict |
_extract_reviewers(pr) |
Builds reviewer string from PR dict |
_build_cross_refs(branches, prs) |
Builds issue↔PR mappings |
2. Container integration tests (in tests/test_image.py)
Add to existing test structure:
- Verify
.devcontainer/scripts/gh_issues.pyexists in the image - Verify
.devcontainer/justfile.ghexists in the image - Verify
richis importable:python -c "from rich.table import Table" - Verify
gh_issues.pyis importable in the container (catches syntax errors, missing imports)
Prerequisite
The uncommitted gh_issues.py changes from the #67 branch (reviewer/assignee columns, _infer_review, _extract_reviewers, _fetch_sub_issue_tree, _build_cross_refs with closing-keyword parsing) should be moved to this issue's branch. These are the functions that need test coverage.
Alternatives Considered
- Test Rich rendering output — fragile, visual, not worth the maintenance cost
- Mock subprocess/gh CLI calls — adds complexity without testing real behavior; save for a future refactoring issue that separates I/O from logic
- Refactor to extract I/O boundaries first — worthwhile but separate scope; test the current pure functions first
Additional Context
- Related: [FEATURE] Add just recipe for GitHub issue and PR dashboard #84 (original script creation), [FEATURE] Consolidate sync-manifest and sync-workspace into a declarative Python manifest #67 (declarative sync manifest)
- The existing
test_manifest_filesintest_image.pyalready partially covers the deployed copy via SHA-256 checksum verification, but doesn't verify importability or runtime deps scripts/gh_issues.pydepends onrich(installed viauv pip install --systemin the Containerfile) andghCLI
Impact
- Tests-only change — no user-visible impact, no changelog entry needed
- Establishes test coverage for a growing utility script
- Container integration tests catch deployment regressions early
Changelog Category
No changelog needed
Activity
gerchowl commentedon Feb 20, 2026
Design
Problem
scripts/gh_issues.pyhas ~540 lines, ~15 functions, and zero test coverage. The original TDD-skip rationale ("no unit-testable logic beyond subprocess calls and rich rendering") no longer holds — the script now contains multiple pure-logic functions fully testable without mocking.The script is deployed via the sync manifest to
.devcontainer/scripts/gh_issues.py, but there is no verification that the deployed copy works inside the container or that runtime dependencies are available.Approach: Two Test Layers
Layer 1: Unit tests (
tests/test_gh_issues.py)Pure-logic functions tested with plain data in, data out — no mocking needed:
_styled(value, style)str, str -> str_extract_label(labels, prefix)list[dict], str -> str_extract_type(labels)list[dict] -> str_extract_scope(labels)list[dict] -> strarea:*labels_clean_title(title)str -> str[FEATURE]etc. prefix_format_assignees(assignees)list[dict] -> str_infer_review(pr)dict -> tuple[str, str]reviewDecision,latestReviews,reviewRequests_extract_reviewers(pr)dict -> str_build_cross_refs(branches, prs)dict, list[dict] -> tuple[dict, dict]Layer 2: Container integration tests (in
tests/test_image.py)Added to existing
TestWorkspaceStructure:.devcontainer/scripts/gh_issues.pyand.devcontainer/justfile.ghpresent in imagerichimportable:python -c "from rich.table import Table"succeedspython -c "import sys; sys.path.insert(0, '/root/assets/workspace/.devcontainer/scripts'); import gh_issues"succeedsPrerequisite
Move the uncommitted
gh_issues.pychanges from the #67 branch to this issue's branch. These contain the functions (_infer_review,_extract_reviewers, enhanced_build_cross_refs) that need test coverage.Out of scope
ghCLI calls (requires GitHub auth)feat(gh-issues): add reviewer, assignee columns and review inference …
gerchowl commentedon Feb 20, 2026
Implementation Plan
Issue: #99
Branch:
feature/99-just-gh-issues-overview-test-coverageTasks
scripts/gh_issues.py—tests/test_gh_issues.py— verify:uv run pytest tests/test_gh_issues.py -v_styled: 3 tests (markup wrapping, empty value, empty style)_extract_label: 7 tests (matching prefix, no match, empty, unknown label, first-match-wins, effort, semver)_extract_type: 6 tests (feature/bug/discussion/chore labels, no type, empty)_extract_scope: 4 tests (single area, multiple areas, no area, empty)_clean_title: 7 tests (all 5 prefixes, no prefix, empty)_format_assignees: 3 tests (empty, single, multiple)_infer_review: 9 tests (3 known decisions, unknown, fallback to latestReviews, last-wins, fallback to reviewRequests, no info, empty dict)_extract_reviewers: 8 tests (no reviews, approved/changes_requested/requested reviewers, mixed, name fallback, empty dict, no-duplicate)_build_cross_refs: 10 tests (branch match, closes/fixes/resolves keywords, case-insensitive, both branch+keyword, no matches, empty inputs, None body, multiple PRs)gh_issues.pyruntime deps —tests/test_image.py— verify:just test-imagetest_rich_importable: verifyfrom rich.table import Tablesucceeds in containertest_gh_issues_importable: verifyimport gh_issuessucceeds (catches syntax errors, missing imports)test_manifest_filesDropped
justrecipe for gh-issues tests: unnecessary —just testalready runs all test filesjustfile.ghexistence test: file does not exist in the repo or manifesttest(gh-issues): add unit tests for pure-logic functions
test(gh-issues): add container integration tests for runtime deps
test(gh-issues): add smoke test for just gh-issues recipe
fix(workspace): add rich to pyproject.toml dependencies
fix(test): use uv run for gh_issues container tests
fix(test): use pre-built venv for gh_issues container tests
gerchowl commentedon Feb 20, 2026
Implementation Plan (Fix: move
richto system-wide install)Issue: #99
Branch:
feature/99-just-gh-issues-overview-test-coveragePR review: #129 (comment)
Context
@c-vigo correctly notes that
richis a devcontainer tool (likepre-commit,ruff), not a project dependency. Users modifypyproject.tomland would unintentionally removerich. It belongs in the Containerfile as a system-wide install.Tasks
rich>=13.0fromassets/workspace/pyproject.toml— restoredependencies = []— verify:git diff assets/workspace/pyproject.tomlrichto system-wide Python tools inContainerfile— add to existinguv pip install --systemline — verify:grep rich Containerfilejustfile.ghto usepython3instead ofuv run python— bothjustfile.gh(source) andassets/workspace/.devcontainer/justfile.gh(deployed copy) — verify:just --list --justfile justfile.ghpython3instead of venv Python —tests/test_image.py— verify:uv run pytest tests/test_image.py -k "test_rich or test_gh_issues_importable" --cojustfile.gh— verify:just sync-workspacefix: install rich system-wide instead of as project dependency
test: add unit, integration, and smoke tests for gh_issues.py (#99) (#…
chore(ci): omit untested CLI scripts from coverage to meet 50% threshold