29 lines
974 B
Python
29 lines
974 B
Python
import pytest
|
|
|
|
from target_simulator.gui import sfp_debug_window
|
|
|
|
|
|
def test_sfpdebugwindow_starts_polling(monkeypatch):
|
|
calls = []
|
|
|
|
# Replace the after method on the class to capture scheduling attempts
|
|
def fake_after(self, ms, callback):
|
|
calls.append((ms, callback))
|
|
return "fake_after_id"
|
|
|
|
monkeypatch.setattr(
|
|
sfp_debug_window.SfpDebugWindow, "after", fake_after, raising=False
|
|
)
|
|
|
|
# Instantiate the window (should call after in __init__)
|
|
w = sfp_debug_window.SfpDebugWindow(master=None)
|
|
|
|
# Ensure at least one scheduling call was made
|
|
assert calls, "SfpDebugWindow did not schedule the polling loop via after()"
|
|
|
|
# Verify that one of the calls uses the configured GUI_POLL_INTERVAL_MS
|
|
assert any(ms == w.GUI_POLL_INTERVAL_MS for ms, _ in calls)
|
|
|
|
# Verify that the callback scheduled is the internal _process_latest_payloads method
|
|
assert any(cb == w._process_latest_payloads for _, cb in calls)
|