Skip to content

test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324

Closed

Description

@dan-petty

Problem

Counts come from one AST pass over tests/test_*.py at 5c45b1e, the head of release/v0.2.28, and [code: …] lines are at the same commit. A file belongs to the package it references most, as in the census.

#1952 deleted commands/release.py and test_release.py with the release code. The release counts and lines below are history, and this item does not change them.

  • Files (6; 7,413 lines, 297 tests [measured: AST pass at 5c45b1e]):

  • Coupling. These files hold 380 patch sites aimed at devops_cli internals and 53 private imports. Every file has some of both [measured]. The internal patches break down as:

    • 96 replace run_gh, 94 of them in commands/pr (58), commands/gh (18) and commands/release (18).
    • 54 replace core.repo.get_repo_origin_name, even though git runs for real (Q23).
    • 29 replace run_subprocess.
    • 12 replace commands.pr.check_binary.
    • 15 replace commands.repos.load_settings.

    A further 74 sites patch shutil.which directly. test_release.py imports 34 private names.

  • Doubles.

    • There are 54 CompletedProcess( and 118 MagicMock( calls, and 4 module-level runner = CliRunner().
    • test_release.py defines ten nested mock_gh* routers, from :509 to :2445.
  • Product code shaped for patching (Q27). commands/release.py:56-85 holds _LAZY_OBJECT_MAPPING (9 names), a module __getattr__ and _get. Its 66 _get(...) calls exist so that tests can patch a name on the command module. refactor(cli): one process runner owns execution, process groups and dry-run #775 plans to replace such blocks with function-local imports.

  • Logic living in commands/ (Q19).

    • Merge readiness [code: commands/pr.py:1209-1805] covers the mergeable state, thread and check-run blockers, perimeter changes, and the grounding rules: one closed issue and its task file.
    • Branch-update planning [code: commands/pr.py:1885-2263].
    • Release:
      • release notes and their limits [code: commands/release.py:333-531];
      • version bumps [code: commands/release.py:532-611];
      • changelog compilation and fragment collection [code: commands/release.py:612-772];
      • service image tags and Argo CD target revisions [code: commands/release.py:146-305];
      • the cut [code: commands/release.py:1059-1200].
    • Rate-limit reads and parsing [code: commands/gh.py:1246-1365].
    • Clone destination parsing [code: commands/repos.py:101-113, :196-228].
  • Edges.

  • Files and names.

    • test_release.py has 2,519 lines and 82 tests. It holds changelog compilation (:1312), fragments (:1471), notes limits (:1681) and the fail-closed cut (:1879).
    • test_pr_cmd.py has 2,291 lines and 101 tests. It holds readiness (:1705-:2202) and a test of the pull request template, a committed file (:2211).
    • test_repos.py has 1,031 lines.
    • Catch-alls: test_release.py:666, :829, :909; test_repos.py:324, :767, :803, :910; test_github_milestones.py:190.
    • 28 test names end in _success, _failure, _basic or _command.

Acceptance criteria

Key questions

Strategic alignment

Proposed design

Problem statement

The test files for devops pr, devops gh and devops repos couple to devops-cli internals through 380 patch sites and 53 private imports. They hold domain logic in commands/ instead of in domain packages. They use ad-hoc doubles instead of the shared edge fakes. This item removes the internal coupling, moves the domain logic into its packages, and reorganizes the tests into behaviour-named files over the shared fakes.

Acceptance criteria

  • Criterion 1: The test files this item owns under tests/commands/ have zero patch sites aimed at devops_cli internals and zero private imports. Tests added elsewhere also have zero of both.
    Verification: Run a grep or AST scan over the owned test files for mock.patch calls targeting devops_cli names and for imports of names starting with an underscore from devops_cli. The count is zero. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ratchet ceilings drop by 380 and 53.
  • Criterion 2: Every edge in the owned tests goes through a shared seam: gh and processes through refactor(cli): one process runner owns execution, process groups and dry-run #775's process fake, GitHub REST through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake, polling through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, settings through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's config fixture, and git runs for real in a temporary repository.
    Verification: No test in the owned files patches run_gh, run_subprocess, shutil.which, time.sleep, load_settings, get_repo_origin_name, or GitHubClient. Each edge is reached through its named fixture. A grep for those names in the owned test files returns zero hits.
  • Criterion 3: No interim unreachable(...) marker remains in this item's test files.
    Verification: A grep for unreachable in the owned test files returns zero hits.
  • Criterion 4: Merge readiness and branch-update planning move into github/ behind a public function. Rate-limit reads and parsing move into github/. Clone destination parsing moves into git/. The commands become thin adapters.
    Verification: The moved logic is reachable through a public function in its domain package. The command module imports and calls it. Tests of the moved logic live in the package's mirror directory under tests/. A move too big for this item gets its own item, and until then its logic is tested through the CLI with edge fakes.
  • Criterion 5: CLI tests use the shared cli fixture, check only parsing, wiring, output and exit codes, and use syrupy snapshots for command tables.
    Verification: No module-level CliRunner() in the owned test files. Command output assertions use syrupy snapshots. Tests assert on exit code, parsed arguments, and output text only.
  • Criterion 6: Where a test builds a domain object, it uses the shared builder from tests/support/builders.py. This item adds no builder of its own.
    Verification: A grep for make_item or equivalent builder calls in the owned test files shows they import from tests.support.builders. No new builder function is defined in the owned files.
  • Criterion 7: The pull request template test moves to tests/invariants/test_pull_request_template.py, named after .github/pull_request_template.md. The subject is added to the list in docs/TESTING.md.
    Verification: The file tests/invariants/test_pull_request_template.py exists and tests the template. The list in docs/TESTING.md under tests/invariants/ includes test_pull_request_template.py.
  • Criterion 8: test_pr_cmd.py and test_repos.py are deleted. Their tests live in behaviour-named files in the mirror directories. The catch-alls are dissolved. Test names state behaviour in CONTEXT.md terms.
    Verification: The two files no longer exist. New files are named after behaviours, such as tests/github/test_merge_readiness.py. No test name ends in _success, _failure, _basic or _command. No test is named after a helper, a private function or a double.
  • Criterion 9: Every line that no public behaviour reaches is deleted, and the 90% changed-line coverage gate passes.
    Verification: Run uv run devops ci. The coverage report shows 90% or more of changed lines covered. No dead code remains in the moved or modified files.
  • Criterion 10: uv run devops ci passes.
    Verification: Run uv run devops ci in a clean checkout. All checks pass with no failures.

Key questions

Fit

Needs splitting into 4 items:

  1. Remove 380 patch sites and 53 private imports from the owned test files; rewire every edge through its shared fake; reorganize tests into behaviour-named files in mirror directories; rename tests to CONTEXT.md terms; dissolve catch-alls; delete test_pr_cmd.py and test_repos.py.
  2. Move merge readiness, branch-update planning and rate-limit reads from commands/ into github/ behind public functions; test in tests/github/. Coordinate with refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998's split of readiness into github/ and roadmap/.
  3. Move clone destination parsing from commands/repos.py into git/ behind a public function; test in tests/git/.
  4. Move the pull request template test to tests/invariants/test_pull_request_template.py and add the subject to the list in docs/TESTING.md.

Suspected block

None.

Dependencies

#1313

Alternatives check of 2026-10-30: not-applicable.
Tool: none found.

Activity

  1. added
    type/test
    scope/cli
    scope/github
    priority/p2-medium
    scope/release
    on Oct 7, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #998, which turns the readiness rules (commands/pr.py:1209-1805) into one verdict: read and blockers in github/, Item rules in roadmap/. Whichever lands second follows that split. Found by the 2026-10-08 backlog review.

  3. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. This is a maintainability improvement within a larger test refactoring effort, not a user-facing defect or security issue.
    • Value: Medium. Reducing 380 internal patch sites and 53 private imports makes the test suite more resilient to refactoring, but it does not add new user-facing capability.
    • Effort: High. Six files totaling 7,413 lines and 297 tests must be rewritten to eliminate all internal patches and private imports, and logic must be relocated into packages.
  4. changed the title [-]test(cli): devops pr, gh, repos and release are thin adapters tested over edge fakes, and merge readiness and release rules are tested in their packages[/-] [+]test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package[/+] on Oct 23, 2026
  5. dan-petty commented on Oct 26, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Priority: P2-Medium. The change improves test quality and maintainability but does not affect core functionality or security.
    • Value: High. Improving test structure and reducing coupling benefits project stability and developer productivity.
    • Effort: Medium. The work requires refactoring tests and may involve changing how internal patches are handled.
    • Related: test(cli): tests double only process edges and mirror the source tree #1307, which asks for a different change. Both items test CLI commands over edge fakes, but the candidate focuses on specific commands and their test structure while #1307 addresses general test practices for all CLI commands.
  6. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    The proposal at 69636b6 needs splitting into 4 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.

    1. Remove 380 patch sites and 53 private imports from the owned test files; rewire every edge through its shared fake; reorganize tests into behaviour-named files in mirror directories; rename tests to CONTEXT.md terms; dissolve catch-alls; delete test_pr_cmd.py and test_repos.py.
    2. Move merge readiness, branch-update planning and rate-limit reads from commands/ into github/ behind public functions; test in tests/github/. Coordinate with refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998's split of readiness into github/ and roadmap/.
    3. Move clone destination parsing from commands/repos.py into git/ behind a public function; test in tests/git/.
    4. Move the pull request template test to tests/invariants/test_pull_request_template.py and add the subject to the list in docs/TESTING.md.
  7. added
    status/new
    effort/medium
    value/high
    on Oct 28, 2026
  8. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Tool: none found

    Checked on 2026-10-30. A person decides what this means for the item. The check changes no label and closes no issue.

  9. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Oct 31, 2026
  10. removed
    status/in-review
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cliscope/githubscope/releasetype/testvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions