enodia-sentinal/tests/test_tray_imports.py
2026-07-08 20:47:58 -07:00

34 lines
1.4 KiB
Python

# SPDX-License-Identifier: GPL-3.0-or-later
"""The tray logic modules must not import GUI libs; pyproject wires the extra."""
import tomllib
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
TRAY = ROOT / "enodia_sentinel" / "tray"
class TestTrayBoundaries(unittest.TestCase):
def test_logic_modules_have_no_gui_imports(self):
for name in ("state.py", "actions.py", "notify.py"):
text = (TRAY / name).read_text()
self.assertNotIn("pystray", text, f"{name} must not import pystray")
self.assertNotIn("PIL", text, f"{name} must not import PIL")
def test_logic_modules_import_without_gui_deps(self):
# These imports must succeed even though pystray/Pillow may be absent.
from enodia_sentinel.tray import actions, notify, state # noqa: F401
def test_pyproject_declares_tray_extra_and_script(self):
data = tomllib.loads((ROOT / "pyproject.toml").read_text())
self.assertIn("tray", data["project"]["optional-dependencies"])
self.assertEqual(
data["project"]["scripts"]["enodia-sentinel-tray"],
"enodia_sentinel.tray.app:main",
)
self.assertEqual(
data["project"]["scripts"]["enodia-sentinel-tui"],
"enodia_sentinel.tui:main",
)
# Core runtime deps stay empty.
self.assertEqual(data["project"]["dependencies"], [])