Repository navigation
Description
Problem or Motivation
Part 5 of 6 of #1335. It needs no other part.
Seven test files of the docker, tf, watchers and Argo CRD code reach their edges through patches. Measured at origin/main 29309f0, with the counting rules of #1335:
| File | Lines | Tests | Patch sites | Private imports |
|---|---|---|---|---|
tests/ai/mcp/test_docker_cosign.py |
599 | 30 | 35 | 1 |
tests/core/test_docker_engine.py |
1,385 | 81 | 12 | 0 |
tests/commands/test_workload_sandbox.py |
332 | 12 | 3 | 0 |
tests/argo/test_argo_crd.py |
519 | 32 | 1 | 1 |
tests/tf/test_tf_analysis.py |
824 | 45 | 0 | 0 |
tests/tf/test_tf_cost.py |
300 | 20 | 9 | 0 |
tests/watchers/test_watchers.py |
191 | 8 | 2 | 0 |
| Total | 4,150 | 228 | 62 | 2 |
None of the 62 sites is a seam site.
What each file patches:
test_docker_cosign.pypatchesshutil.which(16 times),subprocess.run(8),docker.cosign.get_keyring_secret(4),docker.cosign.run_subprocess(3) and methods ofCosignRunner(4). The process fake already answers the PATH lookup and the program. The keyring fake holds the key. The private import is_parse_verification_output.test_docker_engine.pypatchesdocker.engine.CONST_PODMAN_ROOTFUL_SOCKET_PATH(3),CONST_RUN_USER_BASE,http.egress.vet_addresses(2),os.access(2),time.monotonic(2) andos.environ(2).test_workload_sandbox.pypatchesdocker.from_env,docker.DockerClientandtelemetry.tracer._resolve_telemetry_settings.DockerEngineFake(refactor(infra): DockerEngineService is the Docker engine seam, with a shared in-memory engine fake and its contract suite #1316, closed) replaces the first two.test_argo_crd.pypatchesKubernetesService.get_instanceand imports_is_not_found.FakeCluster(refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315, closed) replaces the patch.test_tf_cost.pypatchestf.cost.check_binary(4),tf.cost.run_subprocess(2),tf.cost.run_infracost_diff,commands.tf.is_dry_runandai.mcp.server._run_mcp_cmd. The process fake and the--dry-runflag replace them.test_watchers.pypatchesPath.statand the private method_run_watch_loopof the object under test. The clock fake (refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320) exists.CliRunner()is built at module level intest_docker_engine.py:37,test_workload_sandbox.py:33,test_tf_cost.py:23andtest_tf_analysis.py:30.
Two rules still sit in commands/ (Q19). Both are domain logic, and the CLI tests of #1327 reach them through patches:
- Argo workflow waiting.
_await_workflow(commands/argo.py:134) polls a Workflow until a terminal phase or a timeout. It usestime.monotonicandtime.sleep. It also callsprint_errorandtyper.Exit. - Cloudflare DNS record matching and deletion.
_resolve_dns_target_names,_record_matches_filter,_find_matching_recordsand_execute_dns_deletions(commands/cloudflare.py:438-505) decide which records match a target, a type and the managed comment. They then delete them throughCloudflareClient.
Proposed Solution & Architectural Design
- Replace each patch by the fake or the real object that owns the edge. For the two
vet_addressessites intest_docker_engine.py, take the answers frompublic_dns. refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 replaces that fixture later. - Move the waiting loop into
argo/as a public function. It takes theArgoCRDService, the name, the namespace and the timeout. It returns the state or raises aDevOpsCLIErrorsubclass.commands/argo.pycatches the error and prints. Tests useFakeClusterand theclockfixture. A test that waits in real time is not allowed. - Move the four Cloudflare helpers into
cloudflare/as public functions.commands/cloudflare.pykeeps the rendering and the call. The cases oftests/commands/test_cloudflare_commands.pythat test the matching rule move totests/cloudflare/. The command keeps tests for its wiring only. Do not move other cases of that file. Its other patch sites belong to the finish of test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327. - Replace each private import by a test of the public behaviour. If no public path reaches a private function, delete it as dead code.
- Use the
clifixture. Splittest_docker_engine.py(1,385 lines) by behaviour as a separate commit.
Why _resolve_client of Cloudflare and Valkey does not move: each one turns settings and a keyring secret into a client. That is wiring. The Valkey fake (#1317) and, later, the HTTP fake (#1314) reach the client behind it. The old body asked for the move. This is the reason to drop it.
Why docker/cosign.py needs no new seam: it starts cosign through run_subprocess, the seam of the process edge.
Acceptance criteria
- A test first for the moved waiting function. It returns at once on a terminal phase. It polls on the clock fake until the phase turns terminal. It raises the timeout error when the budget ends. The test takes no real time.
- A test first for each moved Cloudflare function. The cases are matching by name, by id and by type, and the
forceflag that ignores the managed comment. - The seven files hold no patch site and no private import. The pull request comment gives the counts before (62 and 2) and after.
-
commands/argo.pyholds notime.sleepcall.commands/cloudflare.pyholds no matching rule. - The seven files hold no module-level
CliRunner(). -
uv run devops cipasses. The changed lines are covered at 90 percent.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
The fakes exist: ProcessFake, FakeKeyring, DockerEngineFake, FakeCluster and ClockFake (tests/support/fakes/). For the waiting loop, tenacity is in the project (pyproject.toml pins 9.1.4, and TESTING.md names it for retries). Use it only if the loop shrinks. Do not add a new library. The cost to build is about 350,000 tokens. It costs about 15,000 tokens a year to keep. The work takes about 2 days.
Strategic alignment: child of #1335. Parent #1307. Related: #1327 (closed, its files still hold patch sites), #1314, #1336.
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.(infra)scope of the title gives the scope.It improves test maintainability for 7 files but does not fix a user-facing defect or block a release.Replacing 62 patch sites with fakes reduces brittleness and private-import coupling for 228 tests, but the change is internal to the test suite.Seven files, 4,150 lines, 62 patch sites, two rule moves from commands/ to their packages, and private-import removals are all in scope.Both are parts of #1335 that replace test patches with edge fakes, but #3749 covers sandbox test files while the candidate covers docker, tf, watchers, and Argo CRD test files.test(infra): infrastructure tests run on edge fakes (#4283)