# SPDX-License-Identifier: GPL-3.0-or-later """Boundary tests for the desktop GUI package. The logic module must not import tkinter so it can be tested on headless runners; only app.py may import GUI libraries. """ import re import tomllib import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] GUI = ROOT / "enodia_sentinel" / "gui" class TestGuiBoundaries(unittest.TestCase): def test_model_has_no_tkinter_imports(self): text = (GUI / "model.py").read_text() self.assertFalse( re.search(r"\b(import tkinter|from tkinter)\b", text), "model.py must not import tkinter", ) def test_model_imports_without_tkinter(self): # Must succeed even when tkinter is unavailable. from enodia_sentinel.gui import model # noqa: F401 def test_app_module_imports_without_tkinter(self): # The shell is importable without a display/GUI libraries; runtime # use raises a graceful SystemExit when tkinter is absent. from enodia_sentinel.gui import app # noqa: F401 def test_pyproject_declares_gui_script(self): data = tomllib.loads((ROOT / "pyproject.toml").read_text()) self.assertEqual( data["project"]["scripts"]["enodia-sentinel-gui"], "enodia_sentinel.gui.app:main", ) # Core runtime deps stay empty; tkinter is stdlib. self.assertEqual(data["project"]["dependencies"], [])