Add pystray tray applet wiring and [tray] extra

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Luna 2026-07-03 07:37:39 -07:00
parent 2fce7d412a
commit 1451cf7d58
4 changed files with 149 additions and 0 deletions

View file

@ -0,0 +1,30 @@
# 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",
)
# Core runtime deps stay empty.
self.assertEqual(data["project"]["dependencies"], [])