Skip to content

test(viewer): cover gst_fbdev_player.main() and its callbacks (35% → 98%) - #3237

Merged
vpetersson merged 1 commit into
Screenly:masterfrom
vpetersson-bot:test/viewer-coverage
Aug 3, 2026
Merged

test(viewer): cover gst_fbdev_player.main() and its callbacks (35% → 98%)#3237
vpetersson merged 1 commit into
Screenly:masterfrom
vpetersson-bot:test/viewer-coverage

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

Standalone test-coverage improvement for the GStreamer fbdev player (Pi 1/2/3 video path).

Why

src/anthias_viewer/gst_fbdev_player.py sat at ~35% coverage. Its pure helpers (aspect-fit math, caps composition, argv parsing, fb-clear) were tested, but main() — the GStreamer/GLib entry point — was not: it lazily imports gi/Gst/GLib and runs a blocking GLib.MainLoop, so it needs the gi stack stubbed to test at all.

This was split out of the ruff-ruleset PR (#3224), whose codecov report flagged these lines as uncovered (they got pulled into that diff by reformatting). Per review, the coverage work belongs on its own branch rather than bundled into a lint PR.

What

New tests/test_gst_fbdev_player_main.py stubs gi/Gst/GLib in sys.modules and drives the pipeline through mocks. The nested callbacks (bus message, CAPS pad probe, about-to-finish, SIGTERM) are captured from the mock .connect() / .add_probe() / signal.signal() calls and invoked with fake Gst messages/events, so the loop logic runs without a real GStreamer runtime. Covered:

  • startup + teardown, gi-unavailable guard (return 1)
  • audio pre-flight (usable / unusable / no alsasink) and the video-only flags path
  • build_and_start failures: no playbin element, sink-build GLib.Error, PLAYING state failure
  • bus ERROR (video-only exit; audio → rebuild without audio; rebuild-also-fails exit) and EOS (flush-seek loop; seek-refused restart)
  • CAPS probe (pin fit-caps; ignore non-CAPS; incomplete dims; absent PAR)
  • about-to-finish re-queue and SIGTERM quit

Result

gst_fbdev_player.py: 35% → 98% (0 statements uncovered; 4 partial branches remain). 21 new tests; mypy + ruff clean; full viewer suite (302 tests) green. No production code changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HJ3ucEkn62cbgPoisAZ5LQ

gst_fbdev_player.py sat at ~35% coverage — the pure helpers were
tested but main(), the GStreamer/GLib entry point (playbin build, bus
error/EOS/rebuild logic, CAPS pad probe, about-to-finish, SIGTERM), was
not, because it lazily imports gi/Gst/GLib and runs a blocking
GLib.MainLoop.

Add a harness that stubs the gi stack in sys.modules and drives the
pipeline through mocks: the nested callbacks are captured from the mock
.connect()/.add_probe()/signal.signal() calls and invoked with fake Gst
messages/events, so the loop logic is exercised without a real
GStreamer runtime. Raises the module to 98% (0 statements uncovered).

Split out of the ruff-ruleset PR (Screenly#3224) whose codecov report flagged
these lines — this is a standalone coverage improvement.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HJ3ucEkn62cbgPoisAZ5LQ
@vpetersson-bot
vpetersson-bot requested a review from a team as a code owner August 3, 2026 11:49
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@d049783). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3237   +/-   ##
=========================================
  Coverage          ?   90.81%           
=========================================
  Files             ?       76           
  Lines             ?     8352           
  Branches          ?      884           
=========================================
  Hits              ?     7585           
  Misses            ?      549           
  Partials          ?      218           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vpetersson
vpetersson merged commit a03db92 into Screenly:master Aug 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants