# SPDX-License-Identifier: GPL-3.0-or-later """Boundary tests for the Qt GUI frontend. The shared model must stay GUI-free; only qt_app.py may reference PySide6. """ import re import tomllib import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] GUI = ROOT / "enodia_sentinel" / "gui" class TestQtGuiBoundaries(unittest.TestCase): def test_model_has_no_qt_imports(self): text = (GUI / "model.py").read_text() self.assertFalse( re.search(r"\b(import PySide6|from PySide6)\b", text), "model.py must not import PySide6", ) def test_tkinter_app_has_no_qt_imports(self): text = (GUI / "app.py").read_text() self.assertNotIn("PySide6", text, "app.py must not import PySide6") def test_qt_app_imports_without_runtime_gui_deps(self): # qt_app.py guards PySide6 and is importable even when Qt is absent. from enodia_sentinel.gui import qt_app # noqa: F401 def test_pyproject_declares_qt_extra_and_script(self): data = tomllib.loads((ROOT / "pyproject.toml").read_text()) self.assertIn("qt", data["project"]["optional-dependencies"]) self.assertEqual( data["project"]["scripts"]["enodia-sentinel-gui-qt"], "enodia_sentinel.gui.qt_app:main", )