30 lines
1.3 KiB
Python
30 lines
1.3 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",
|
|
)
|
|
# Core runtime deps stay empty.
|
|
self.assertEqual(data["project"]["dependencies"], [])
|