blissoda.tests.test_stop_scan_preset#

Unit tests for the StopIntegrateSum attenuation “freeze-mode” state machine.

These tests drive ScanPointIterator._frame0_setup_step directly with a mocked parent preset, no Bliss session is needed. Integration tests are not adequate to check freeze mode as the demo Bliss detector (difflab6) does not respond to changes in attenuation (e.g. via setup_globals.atten.bits).

Functions

test_event_dispatch_drops_malformed_metric(caplog)

Malformed metric events are logged and dropped without crashing.

test_event_dispatch_metric_stop_unknown(caplog)

_check_workflow_events routes each event type to the right sink.

test_freeze_classification_timeout(caplog, ...)

No frame-0 metric within metric_timeout → default to 'standard'.

test_freeze_spotty_stable()

Spotty-stable branch runs the safe-frame loop then adds extra atten.

test_freeze_spotty_unstable()

Spotty-unstable branch keeps safe_atten and freezes immediately.

test_freeze_standard_convergence()

Standard-branch safe-frame loop converges and then freezes attenuation.

test_freeze_standard_decrement_then_below_threshold()

Frame 0 below threshold and stepping down stays below → keep stepping down until the predict-back-up check triggers the final +1 hysteresis.

test_invalid_attenuation_mode_raises(mocker)

test_reactive_mode_does_not_run_frame0_setup()

In reactive mode, _frame0_setup_step is never entered.