43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Speed authority between a locator socket client and the GUI field.
|
|
|
|
The data_processor uses the speed a socket client streams unless the live config
|
|
sets `ignore_socket_speed`; then `gpr_speed_m_s` from the GUI field applies. Each
|
|
GPR-like page (gpr, sar3d) has its own checkbox and field, and the
|
|
field is editable only while it is the one in force.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import unittest
|
|
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
from PyQt6.QtWidgets import QApplication # noqa: E402
|
|
|
|
from python_app.gui.app_window import AppWindow # noqa: E402
|
|
from python_app.tests.gui_test_support import isolated_window
|
|
|
|
_app: QApplication | None = None
|
|
_window: AppWindow | None = None
|
|
|
|
def setUpModule() -> None:
|
|
global _app, _window
|
|
instance = QApplication.instance()
|
|
_app = instance if isinstance(instance, QApplication) else QApplication([])
|
|
_window = isolated_window(unittest.addModuleCleanup)
|
|
|
|
|
|
class SocketSpeedControlsTest(unittest.TestCase):
|
|
def test_socket_authority_controls_editability_and_published_speed(self) -> None:
|
|
assert _window is not None
|
|
section = _window._view.processing
|
|
for mode, (checkbox, speed) in zip(("gpr", "sar3d"), section.speed_controls, strict=True):
|
|
section.mode.setCurrentText(mode)
|
|
speed.setValue(1.25)
|
|
for ignore in (True, False):
|
|
checkbox.setChecked(ignore)
|
|
self.assertEqual(speed.isEnabled(), ignore, msg=mode)
|
|
config = _window._live.build()
|
|
self.assertEqual(config.ignore_socket_speed, ignore, msg=mode)
|
|
self.assertAlmostEqual(config.gpr_speed_m_s, 1.25, msg=mode)
|