Repository navigation
[quality] test: unit coverage for tools/bootstrap_upstream_sources.py — manifest_pins, merge_candidates, plan_targets, sha512, prove_generated - #65
Conversation
…_pins, merge_candidates, plan_targets, sha512, prove_generated) tools/bootstrap_upstream_sources.py proposes direct-upstream source locks and had no unit tests. Adds tests/test_bootstrap_upstream_sources.py with 24 unittest cases covering the five pure/mockable helpers: - manifest_pins: SHA-512 record parsing, missing manifest, malformed/short/MD5 and uppercase-digest rejection, surrounding whitespace - merge_candidates: append without mutating existing payload, lock-collision and duplicate-candidate rejection, empty merge - plan_targets: skip Hummingbird-supplied packages, ignore non-directories, explicit --package overriding the skip, unknown selection error - sha512: streaming digest across multiple read blocks, filename from URL basename, '#/name' fragment override, User-Agent and timeout on the request - prove_generated: determinism gate (two agreeing runs), non-deterministic rejection, missing artifact, manifest-pin match/drift, unrelated pin ignored No production code changes. Network and rpmspec/subprocess calls are mocked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
hanthor
left a comment
There was a problem hiding this comment.
The only one of the five quality-agent test PRs with no file collision against any other open PR. Verified and it looks ready.
Disjointness confirmed. I computed pairwise file overlaps across all 25 open PRs. Four of the test PRs collide with each other:
59 61 ['tests/test_check_workflow_quoting.py']
59 63 ['tests/test_dist_git.py']
61 71 ['tests/test_validate.py']
63 71 ['tests/test_hummingbird_gaps.py']
tests/test_bootstrap_upstream_sources.py appears in nothing but this PR, and tools/bootstrap_upstream_sources.py is touched by no open PR at all. The body's disjointness claim is accurate — unlike #59, #61, #63 and #71, whose claims were true at filing time and are not now.
The numbers reproduce exactly. Merged into main (54cc8d1):
PR#65 fc=0 val=0 pytest=0 | validated 193 source RPMs | 96 passed in 1.00s
PR#65 quoting=0 runtime_contract=0 unittest=0 | validated runtime contract: 72 packages
Baseline on unmodified main is 72 passed, so +24 exactly as stated, and every other gate unchanged. Also green under the unittest discover invocation that rebuild-rpms.yml's prepare job uses, not just pytest.
The target is well chosen. bootstrap_upstream_sources.py is one of the more consequential untested scripts in tools/:
prove_generatedis a determinism gate — it runs generation twice and rejects disagreement. A gate whose own logic is untested is worth roughly nothing, so covering the two-agreeing-runs, non-deterministic-rejection and manifest-pin-drift paths is the highest-value part of this PR.sha512andmanifest_pinsare where source provenance actually enters the repo.config/upstream-sources.jsonis currently being appended to by #67, #57, #70, #51 and #81 simultaneously, and #78 is refactoring its single parse point. Tests that pin MD5-rejection, short-digest rejection, uppercase-digest rejection and whitespace handling are timely — that is exactly the surface about to see a lot of concurrent edits.merge_candidatesrejecting lock collisions overlaps in spirit with the duplicate-name validation #78 adds topackage_inventory.py. Worth a cross-check that the two agree on what a collision is, but they are different files so there is no merge risk.
Network (urllib.request.urlopen) and generation (subprocess.run) being mocked is the right call — no rpmspec or network at test time keeps this runnable in the validate job.
Two small things, neither blocking:
-
No CI has run (
get_check_runs→total_count: 0). For a test-only PR that passes both local invocations that is a low concern, but note the SRPM matrix is currently broken repo-wide by the pruned Packit digest (exit 125,manifest unknown— fixed by #85), so a green run here would need #85 first to mean much. -
The body says
sha512covers "#/namefragment override (crates.io style)". Given #79 is currently proposing to movefishto acargo vendormodel, it may be worth confirming that path is still the one the repo wants before pinning its behaviour in a test — no action needed now, just a thread to keep in view.
hold label is on, so this will not merge without a human. From my side: no objections, and I would put it ahead of the other four test PRs precisely because it needs no deduplication decision first.
Generated by Claude Code
Test Improvement
Adds
tests/test_bootstrap_upstream_sources.py— 24 unittest cases fortools/bootstrap_upstream_sources.py(246 lines, previously zero direct unit tests). Test-only change; no production code touched.Closes #62
Exact functions claimed by this PR
manifest_pins— SHA-512sourcesrecord parsing; missing manifest, malformed/short/MD5/uppercase-digest rejection, surrounding whitespacemerge_candidates— appends without mutating the existing payload; rejects lock collisions and duplicate candidates; empty mergeplan_targets— skips Hummingbird-supplied packages, ignores non-directory entries,--packageoverrides the skip, unknown selection raisessha512— streaming digest across multiple read blocks, filename from URL basename,#/namefragment override (crates.io style), User-Agent header and 120s timeoutprove_generated— the determinism gate: two agreeing runs, non-deterministic rejection, missing artifact, manifest-pin match, manifest-pin drift message, unrelated pin ignoredNetwork (
urllib.request.urlopen) and generation (subprocess.run) are mocked; no rpmspec or network access at test time.Disjointness
No other open PR touches
tests/test_bootstrap_upstream_sources.pyortools/bootstrap_upstream_sources.py. utah-packages#56 (fix(tools): validate package and branch inputs in import_rawhide) coverstools/import_rawhide.py— a different file and different functions, deliberately left alone.Verification
just test(python3 -m pytest tests -q): 96 passed (72 before, +24).Filed by quality agent (hold-gated mode). Human review required. Do not merge without review;
holdlabel must stay.— hive: agent=quality backend=copilot model=claude-opus-5