* chore: bump minimum Python from 3.8 to 3.9 and adopt PEP 585 builtins - Update requires-python, classifiers, mypy target, and black target in pyproject.toml - Replace Python 3.8 with 3.9 in CI matrix and nightly workflow - Replace typing.List/Dict/Tuple/Set with builtin list/dict/tuple/set (PEP 585) - Update all 3.8 version references in README, docs, website, and install.sh - Fix test_wayland_no_tools to mock IBus availability - Remove List from common_types re-exports and update test * style: reformat test files for Black 26.x and pin version in CI Black 26.x introduced parenthesized context manager formatting. Reformat 7 test files and pin Black>=26,<27 in CI to prevent future drift from unpinned version upgrades.
52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
from vocalinux.ui import autostart_manager
|
|
|
|
|
|
class TestAutostartManager(unittest.TestCase):
|
|
def test_get_autostart_dir_uses_xdg_config_home(self):
|
|
with patch.dict("os.environ", {"XDG_CONFIG_HOME": "/tmp/vlx-config"}, clear=False):
|
|
autostart_dir = autostart_manager.get_autostart_dir()
|
|
self.assertEqual(autostart_dir, Path("/tmp/vlx-config") / "autostart")
|
|
|
|
def test_get_exec_command_prefers_installed_command(self):
|
|
with patch(
|
|
"vocalinux.ui.autostart_manager.shutil.which",
|
|
return_value="/usr/bin/vocalinux",
|
|
):
|
|
command = autostart_manager.get_exec_command()
|
|
self.assertEqual(command, "/usr/bin/vocalinux --start-minimized")
|
|
|
|
def test_get_exec_command_falls_back_to_python_module(self):
|
|
with (
|
|
patch("vocalinux.ui.autostart_manager.shutil.which", return_value=None),
|
|
patch("vocalinux.ui.autostart_manager.sys.executable", "/usr/bin/python3"),
|
|
patch("vocalinux.ui.autostart_manager.sys.frozen", new=False, create=True),
|
|
):
|
|
command = autostart_manager.get_exec_command()
|
|
self.assertEqual(command, "/usr/bin/python3 -m vocalinux.main --start-minimized")
|
|
|
|
def test_enable_disable_autostart_creates_and_removes_entry(self):
|
|
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
with (
|
|
patch.dict("os.environ", {"XDG_CONFIG_HOME": tmp_dir}, clear=False),
|
|
patch(
|
|
"vocalinux.ui.autostart_manager.shutil.which",
|
|
return_value="/usr/bin/vocalinux",
|
|
),
|
|
):
|
|
enabled = autostart_manager.enable_autostart()
|
|
self.assertTrue(enabled)
|
|
|
|
desktop_file = Path(tmp_dir) / "autostart" / "vocalinux.desktop"
|
|
self.assertTrue(desktop_file.exists())
|
|
content = desktop_file.read_text(encoding="utf-8")
|
|
self.assertIn("Exec=/usr/bin/vocalinux --start-minimized", content)
|
|
|
|
disabled = autostart_manager.disable_autostart()
|
|
self.assertTrue(disabled)
|
|
self.assertFalse(desktop_file.exists())
|