35 lines
1.8 KiB
Python
35 lines
1.8 KiB
Python
"""Every native live setting has one declaration or an explicit runtime source."""
|
|
|
|
from dataclasses import fields
|
|
import unittest
|
|
|
|
from python_app.models.setting_fields import GUI_FIELDS, active_live_fields, active_web_fields
|
|
from python_app.orchestration.live_processing_config import ProcessingLiveConfig
|
|
|
|
|
|
class LiveSettingsSchemaCoverageTest(unittest.TestCase):
|
|
def test_bindings_cover_live_config_and_select_each_page_once(self) -> None:
|
|
config_names = {field.name for field in fields(ProcessingLiveConfig)}
|
|
runtime = {"reprocess_current_result", "history_clear_before_ns", "history_removed", "settings_revision"}
|
|
geometry = {"tx_geometry", "rx_geometry"}
|
|
modes = next(binding.spec.choices for binding in GUI_FIELDS if binding.spec.live == "processor_mode")
|
|
widget_names = [binding.spec.widget for binding in GUI_FIELDS if binding.spec.widget]
|
|
self.assertEqual(len(widget_names), len(set(widget_names)))
|
|
for mode in modes:
|
|
with self.subTest(mode=mode):
|
|
live = active_live_fields(mode)
|
|
live_names = {binding.spec.live for binding in live}
|
|
self.assertEqual(len(live), len(live_names))
|
|
self.assertEqual(live_names | geometry | runtime, config_names)
|
|
self.assertFalse(live_names & (geometry | runtime))
|
|
web = active_web_fields(mode)
|
|
web_names = {binding.spec.web for binding in web}
|
|
self.assertEqual(len(web), len(web_names))
|
|
self.assertIn("processor_mode", web_names)
|
|
self.assertTrue(all(binding.mode in (None, mode) for binding in web))
|
|
self.assertFalse({binding.spec.web for binding in web if not binding.spec.live} & config_names)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|