Skip to content

testing

Test doubles for use in downstream projects.

omgrab.testing

Shared test doubles and helpers for omgrab unit tests.

This module provides reusable fake implementations of hardware-dependent components. Import fakes directly in test files, or use the convenience fixtures defined in conftest.py.

FakeGPIOController()

Bases: GPIOController

Test double for GPIOController that records all calls.

Subclasses GPIOController but overrides init to avoid spawning a subprocess or importing hardware-specific modules.

set_led_states(red, green)

Record LED state change.

set_buzzer(state)

Record buzzer on/off.

set_buzzer_volume(volume)

Record buzzer volume change.

set_buzzer_tone(freq)

Record buzzer tone change.

read_button()

Return the preconfigured button state.

buzzer_beep(duration=0.1, count=1)

Record a beep request.

cleanup()

Record cleanup.

FakeCaptureDevice(*, connected=True, ready=True, device_type=None)

Test double for CaptureDevice that simulates device lifecycle.

label property

Return the device label.

connected property

Return whether the device is connected.

ready property

Return whether the device is ready.

device_type property

Return the device type identifier.

wait_until_ready(timeout=None)

Wait until the device is ready.

preview()

Return a preview context manager.

make_snapshot(status=network_monitor.Status.ONLINE, detail='test')

Create a network Snapshot for testing.