Skip to content

test: executed coverage for tools/import_bluefin_rawhide.py — new tests/test_import_bluefin_rawhide.py (resolve_source, main) - #107

Merged
hanthor merged 1 commit into
mainfrom
quality/test-import-bluefin-rawhide
Sep 18, 2026
Merged

hanthor merged 1 commit into
mainfrom
quality/test-import-bluefin-rawhide

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/test_import_bluefin_rawhide.py — 15 unittest cases covering tools/import_bluefin_rawhide.py, which had no test file and 0% executed coverage (60/60 statements missed).

Exact ground this PR claims

  • New file: tests/test_import_bluefin_rawhide.py
  • Module under test: tools/import_bluefin_rawhide.py — functions resolve_source() and main()
  • No production file is modified. This is a test-only change.

What is covered

resolve_source()

  • derives the source name from a sourcerpm and passes the expected dnf repoquery argv
  • de-duplicates candidates and takes the first sorted one
  • treats the (none) marker as "no candidate"
  • reports stderr as the reason when repoquery returns nothing usable
  • turns an unparseable candidate into an explicit reason string rather than a traceback

main()

  • happy path: report contents, imported_sources ordering, and the tools/import_rawhide.py argv
  • creates the report's parent directory
  • [unavailable] packages policy excludes binaries before any query is issued
  • an absent policy file leaves every binary in scope
  • unresolved binaries land in unavailable with their reason
  • total resolution failure raises the "refusing to open a flood of issues" abort before importing anything
  • an existing destination short-circuits the import
  • a failed import is recorded, is not counted as imported, and falls back to stdout when stderr is empty
  • two binaries sharing one source are imported once

Every test stubs the module-level command() wrapper, so no dnf or fedpkg process is ever spawned and the tests need no network.

Measured result

tools/import_bluefin_rawhide.py   60 stmts   0% -> 97%
tools/ overall                              54% -> 58%

The two remaining uncovered lines are the subprocess.run wrapper body and the __main__ guard.

Both CI runners are green with the new file:

  • python3 -m pytest tests -q (validate.yml) — 196 passed
  • python3 -m unittest discover -s tests (rebuild-rpms.yml) — 196 tests, OK

Mutation-checked: inverting the destination.exists() short circuit and neutering the [unavailable] policy filter each fail exactly one targeted test.

Disjointness from open PRs

No other open PR touches tools/import_bluefin_rawhide.py or tests/test_import_bluefin_rawhide.py:

Related Issue

Closes #106


Filed by quality agent (hold-gated mode). Human review required. Do not merge without review; the hold label stays on.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78

tools/import_bluefin_rawhide.py had no test file and 0% executed coverage
(60/60 statements missed). The shared grammar it consumes
(tools/rawhide_sources.py) is fully covered by tests/test_rawhide_sources.py,
but the tool's own two functions were never executed by the suite.

Adds tests/test_import_bluefin_rawhide.py with 15 unittest cases covering:

resolve_source()
  - derives the source name from a sourcerpm and passes the expected
    dnf repoquery argv
  - de-duplicates and takes the first sorted candidate
  - treats the "(none)" marker as no candidate
  - reports stderr as the reason when repoquery returns nothing
  - turns an unparseable candidate into an explicit reason, not a traceback

main()
  - happy path: report contents, imported_sources ordering, and the
    tools/import_rawhide.py argv
  - creates the report parent directory
  - [unavailable] packages policy excludes binaries before any query
  - an absent policy file leaves every binary in scope
  - unresolved binaries land in "unavailable" with their reason
  - total resolution failure aborts before importing anything
  - an existing destination short-circuits the import
  - a failed import is recorded, not counted as imported, and falls back
    to stdout when stderr is empty
  - two binaries sharing one source are imported once

Every test stubs the module-level command() wrapper, so no dnf or fedpkg
process is spawned. Coverage for the module goes 0% -> 97% (only the
subprocess wrapper body and the __main__ guard remain), and tools/ overall
goes 54% -> 58%.

Test-only change: no production file is modified. Green under both CI
runners, python3 -m pytest tests -q (validate.yml) and
python3 -m unittest discover -s tests (rebuild-rpms.yml).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added hold Work is intentionally paused. agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq labels Sep 14, 2026
@hivecommons-hive hivecommons-hive Bot changed the title [quality] test: executed coverage for tools/import_bluefin_rawhide.py — new tests/test_import_bluefin_rawhide.py (resolve_source, main) test: executed coverage for tools/import_bluefin_rawhide.py — new tests/test_import_bluefin_rawhide.py (resolve_source, main) Sep 17, 2026
@hivecommons-hive hivecommons-hive Bot added the agent/scanner Filed or owned by the scanner agent. label Sep 17, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Deferring this PR's red checks: the cause is a repository-wide pin, not this diff.

This branch adds tests/test_import_bluefin_rawhide.py only. The precedence
job never reaches any test — it dies pulling the pinned build container:

docker: Error response from daemon: manifest for quay.io/fedora/fedora@sha256:a58a82ed658c109c104e97fdcce52690337cff52e68dc8fa9c033a5fe38dfeec not found: manifest unknown
##[error]Process completed with exit code 125

Every rebuild*/build (...) job in this run fails the same way, and the same
failure is present across unrelated open PRs in this repository. Refreshing
those digests is exactly what the open PRs #116 and #122
("fix(ci): refresh missing Fedora and Packit image digests") do.

Nothing in a test-only diff can resolve an unpublished base digest, so this PR
waits for that repair rather than being retried here.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78

@hanthor
hanthor merged commit 61cadd1 into main Sep 18, 2026
5 of 139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Filed or owned by the quality agent. agent/scanner Filed or owned by the scanner agent. hold Work is intentionally paused.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] tools/import_bluefin_rawhide.py has zero test coverage — no test file exists

1 participant