some webUI fixes
This commit is contained in:
@@ -27,6 +27,7 @@ from python_app.gui.controllers.app_window_web_mixin import ( # noqa: E402
|
||||
AppWindowWebMixin,
|
||||
)
|
||||
from python_app.models.dataset_model import ComboKey, SweepCollection, TraceData # noqa: E402
|
||||
from python_app.storage.npz.paths import radar_config_filename_prefix # noqa: E402
|
||||
from python_app.storage.npz.store import NpzStore # noqa: E402
|
||||
from python_app.storage.npz.vna_history_json import ( # noqa: E402
|
||||
_complex_to_points,
|
||||
@@ -84,6 +85,29 @@ class NpzStoreRoundTripTest(unittest.TestCase):
|
||||
self.store.load_set("calibration", "radar1", "absent")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Radar-config filename prefix
|
||||
# --------------------------------------------------------------------------- #
|
||||
class RadarConfigPrefixTest(unittest.TestCase):
|
||||
def test_encodes_model_span_points_power(self) -> None:
|
||||
self.assertEqual(
|
||||
radar_config_filename_prefix("librevna", 1e9, 6e9, 201, -10.0),
|
||||
"librevna_1-6GHz_201pts_-10dBm",
|
||||
)
|
||||
|
||||
def test_megahertz_span_keeps_fractional_values(self) -> None:
|
||||
self.assertEqual(
|
||||
radar_config_filename_prefix("librevna", 1.5e6, 6e6, 51, -3.5),
|
||||
"librevna_1.5-6MHz_51pts_-3.5dBm",
|
||||
)
|
||||
|
||||
def test_adc_model_reports_adc_point_count(self) -> None:
|
||||
self.assertEqual(
|
||||
radar_config_filename_prefix("kamil_adc", 1e9, 6e9, 1, 0.0),
|
||||
"kamil_adc_1-6GHz_adc_0dBm",
|
||||
)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# vna_history export
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -121,7 +145,12 @@ class VnaHistoryTest(unittest.TestCase):
|
||||
# --------------------------------------------------------------------------- #
|
||||
class WebControllerTest(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.controller = AppWindowWebController()
|
||||
self._cfg_dir = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self._cfg_dir.cleanup)
|
||||
self.configs_dir = Path(self._cfg_dir.name)
|
||||
(self.configs_dir / "alpha.json").write_text("{}", encoding="utf-8")
|
||||
(self.configs_dir / "beta.json").write_text("{}", encoding="utf-8")
|
||||
self.controller = AppWindowWebController(self.configs_dir)
|
||||
self.addCleanup(self.controller.deleteLater)
|
||||
|
||||
def test_rejects_unknown_field(self) -> None:
|
||||
@@ -160,6 +189,25 @@ class WebControllerTest(unittest.TestCase):
|
||||
self.controller.capture_tmp_reference()
|
||||
self.assertEqual(fired, ["start", "stop", "single", "capture"])
|
||||
|
||||
def test_lists_configs_sorted_and_load_emits_signal(self) -> None:
|
||||
self.assertEqual(self.controller.list_configs(), ["alpha.json", "beta.json"])
|
||||
requested: list[str] = []
|
||||
self.controller.load_config_requested.connect(requested.append)
|
||||
self.controller.load_config("beta.json")
|
||||
self.assertEqual(requested, ["beta.json"])
|
||||
|
||||
def test_load_config_rejects_unknown_or_unsafe_name(self) -> None:
|
||||
# Missing file, traversal, sub-path, and non-json are all refused (HTTP 400 upstream).
|
||||
for bad in ("ghost.json", "../escape.json", "sub/alpha.json", "alpha.txt"):
|
||||
with self.assertRaisesRegex(ValueError, "Unknown run config"):
|
||||
self.controller.load_config(bad)
|
||||
|
||||
def test_save_dataset_forwards_path_and_name(self) -> None:
|
||||
received: list[tuple[str, str]] = []
|
||||
self.controller.save_dataset_requested.connect(lambda p, n: received.append((p, n)))
|
||||
self.controller.save_dataset("/tmp/out", "run1")
|
||||
self.assertEqual(received, [("/tmp/out", "run1")])
|
||||
|
||||
|
||||
class WebPortTest(unittest.TestCase):
|
||||
def _port_with_env(self, value: str | None) -> int:
|
||||
|
||||
Reference in New Issue
Block a user