Repository navigation
Description
Problem or Motivation
Issue #1327 is closed as completed. Its goal was that the command tests double only edges. At origin/main cfee381 (2026-11-06), the command tests still patch names inside devops_cli.
Measured with git grep on tests/commands:
- 869 string patches of a
devops_cliname (monkeypatch.setattr,mock.patchandpatch). - 740 of them target a name inside
devops_cli.commands, such ascommands.valkey._resolve_client(24 references intest_valkey.py) andcommands.cloudflare.load_settings(20 intest_cloudflare_commands.py). - 64 of the 129 test files of
tests/commandshold at least one of these patches. - The largest files:
k8s/test_k8s.py(134),test_pr_cmd.py(47),test_repos.py(41),test_ci.py(40),test_test_selection.py(39),test_gh_cmd.py(37),test_cloudflare_commands.py(36) andk8s/test_k8s_bootstrap.py(29).
Issue #1336 turns the ratchets of #1309 into bans. It will fail on these patches. So this work blocks #1336.
Proposed Solution & Architectural Design
Replace each internal patch with a double of the edge that the command reaches: the process fake, the HTTP fake, the GitHub fake, the Kubernetes fake or the settings fixture of tests/support/config.py. Follow the rules of docs/TESTING.md and the pattern that #1323, #1325 and the adapters of #1327 used.
The work is too large for one pull request. Split it by command group, one pull request for each group, and keep the order of the largest files first:
k8s/command tests.pr,ghandreposcommand tests.ciandtest_selectioncommand tests.cloudflare,valkeyand the remaining command tests.
Each pull request states its count of patches before and after. The ceiling of the ratchet then goes down with each pull request.
Acceptance criteria for the whole item:
git grepfinds no string patch of adevops_cliname intests/commands.- Each command keeps the tests that it had, and the behavior that each test checks does not change.
- test(cli): Convert ratchets to bans and merge invariant tests #1336 can turn its ratchet for this directory into a ban.
Target Subsystem
SDLC, Git & PR Governance.
Existing Tool Considered
No new tool is needed. The fakes of tests/support/fakes/, the config fixture and pytest already cover this. The cost of building the fakes is already paid by #1313, #1315 to #1320 and #1323 to #1325.
Proposed design
Problem statement
The command tests double names inside devops_cli instead of the edges that the commands reach. At cfee381, tests/commands holds 869 string patches of a devops_cli name, and 64 of its 129 test files hold at least one. The patches break the rule of docs/TESTING.md and stop #1336 from turning its ratchet into a ban.
Acceptance criteria
Requirement: The command tests patch no devops_cli name
The test files under tests/commands SHALL hold no string patch of a devops_cli name.
Scenario: The command tests are searched for a patch of a devops_cli name
- WHEN a run searches
tests/commandsformonkeypatch.setattr,mock.patchandpatchcalls that name adevops_climodule - THEN the search finds no match and exits with status 0
Requirement: A command keeps its tests
Each command test file SHALL keep every test that it held before the change.
Scenario: The collected tests of the command tests before and after the change
- WHEN a run collects the tests of
tests/commandson the base commit and on the changed commit - THEN the changed commit collects every test identifier that the base commit collected, and each one passes
Requirement: A test sets configuration through the config fixture
A command test SHALL set configuration through the config fixture and SHALL NOT patch load_settings or a config path.
Scenario: A command test needs a setting that differs from the default
- WHEN a converted test needs a setting that differs from its default
- THEN the test writes the setting through the
configfixture and patches no settings name
Requirement: A test reaches an edge through its fake
A command test SHALL reach each edge through the fake of that edge and SHALL install no patch of a devops_cli name.
Scenario: A converted test reaches the process edge
- WHEN a converted test runs a command that starts a program
- THEN the fake records the call, and the test installs no patch of a
devops_cliname
Requirement: Each pull request states its patch count
Each pull request of the split SHALL state the count of string patches of a devops_cli name in its command group before and after the change.
Scenario: The patch count of a command group after its pull request
- WHEN a run counts the string patches of a
devops_cliname in the group's test files after the change - THEN the count is lower than the count on the base commit and equals the number that the pull request body states
Existing Tool Considered
No alternatives check has run. No new tool is needed, and the change writes no code of its own. pytest, with the fakes of tests/support/fakes/ (process, HTTP, GitHub, Kubernetes, Valkey), the config fixture of tests/support/config.py and the cli fixture, covers the need. They lack a double for logic that sits in commands/ and is no edge: that logic moves into its domain package.
Key questions
- Which double replaces a patch of a
devops_cliname in a command test?: Install the fake of the edge that the command reaches through its fixture:process_fake,web,github_api,cluster,valkeyor theconfigfixture. The test asserts on what the fake recorded, and it patches nodevops_cliname. (best practice) [sources: docs/TESTING.md, docs/adr/0007-tests-double-only-process-edges.md, tests/support/config.py]- Chosen: The fake of the edge, through its fixture. docs/TESTING.md gives one fake for each edge and forbids a patch of a
devops_cliname. - Rejected: A patch of the stdlib or of the SDK object. docs/TESTING.md allows it only for an edge that no seam reaches, and never at a
devops_cliname. - Rejected: Keep the patch under a ceiling. The goal is a ban, and a ceiling keeps the patch.
- Chosen: The fake of the edge, through its fixture. docs/TESTING.md gives one fake for each edge and forbids a patch of a
- What does a test do when the patched name is command-layer logic and not an edge?: Move the logic into its domain package behind a public function and test it there. The command becomes a thin adapter, and the CLI test reaches only the edge. (best practice) [sources: docs/TESTING.md]
- Chosen: Move the logic into its domain package. docs/TESTING.md requires that logic behind a private helper in
commands/moves to its domain package. - Rejected: Keep the patch with a marker. A marked patch still fails the ban of test(cli): Convert ratchets to bans and merge invariant tests #1336.
- Rejected: Delete the test. The command would lose the behavior that the test checks.
- Chosen: Move the logic into its domain package. docs/TESTING.md requires that logic behind a private helper in
- Which fixture replaces a patch of
load_settingsor of a config path?: Theconfigfixture intests/support/config.py. It writes the overrides into the test's ownconfig.yamland resets the settings cache. [sources: tests/support/config.py, docs/TESTING.md] - Which double does a test use when no fake reaches its edge?: Use a parameter that the code already takes, a shared double already in
tests/, or the stdlib fallback. If none reaches the edge, patch the SDK object at the SDK's own module, never adevops_cliname. A new fake goes totests/support/fakes/<edge>.pyand comes with its contract suite. (best practice) [sources: docs/TESTING.md]- Chosen: A parameter the code takes, a shared double, or the stdlib fallback. docs/TESTING.md names these in this order and forbids a patch of devops-cli.
- Rejected: The SDK object at the SDK's own module. It is the last fallback, for an edge that none of the three reaches.
- Rejected: The
devops_cliname, with a comment. It is the patch that this item removes.
- How is the work split, and in which order?: Four pull requests, one for each command group, largest files first:
k8s, thenpr/gh/repos, thenci/test_selection, thencloudflare/valkeyand the rest. Each pull request states its count of patches before and after. (best practice) [sources: docs/TESTING.md]- Chosen: One pull request for each command group. 869 patches in 64 files exceed one pull request, and the ratchet ceiling goes down once per pull request.
- Rejected: One pull request for the whole directory. The change is too large for one review.
- Rejected: One pull request for each test file. 64 pull requests cost more review time than four.
- How does a run count the patches of a command group?: With the
git grepform thatdocs/TESTING.mdfixes:-n -I -Fand a plain literal, or-eliterals before--and the relative paths. The count ofmonkeypatch.setattr,mock.patchandpatchcalls that namedevops_cligives the number. [sources: docs/TESTING.md]
Fit
Needs splitting into 4 items:
k8scommand tests: the files oftests/commands/k8s/, withtest_k8s.py(134 patches) andtest_k8s_bootstrap.py(29) first.pr,ghandreposcommand tests:test_pr_cmd.py(47 patches),test_repos.py(41) andtest_gh_cmd.py(37).ciandtest_selectioncommand tests:test_ci.py(40 patches) andtest_test_selection.py(39).cloudflare,valkeyand the remaining command tests:test_cloudflare_commands.py(36 patches),test_valkey.py(24) and the rest.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-08: not-applicable.
Class: test, no search.
Tool: none found.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(cli)scope of the title gives the scope.It blocks #1336 but is a test refactoring, not a production defect.It improves test maintainability and unblocks #1336 but does not change user-facing behavior.869 patches across 64 files split into four pull requests.Both target removing internal patches from command tests; #1307 is the umbrella that defines the edge-fake rule, while the candidate is the specific remaining work in tests/commands.devops-cli-service commentedon Nov 7, 2026
The proposal at 72c52c6 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.
k8scommand tests: the files oftests/commands/k8s/, withtest_k8s.py(134 patches) andtest_k8s_bootstrap.py(29) first.pr,ghandreposcommand tests:test_pr_cmd.py(47 patches),test_repos.py(41) andtest_gh_cmd.py(37).ciandtest_selectioncommand tests:test_ci.py(40 patches) andtest_test_selection.py(39).cloudflare,valkeyand the remaining command tests:test_cloudflare_commands.py(36 patches),test_valkey.py(24) and the rest.test(cli): cloudflare, valkey and other command tests patch no names (#…
devops-cli-service commentedon Nov 8, 2026
Alternatives check: not-applicable
Class: test. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.