feat(dictate): support configurable ASR backends
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import os
|
||||
import subprocess
|
||||
@@ -24,8 +25,11 @@ class InstallerTests(unittest.TestCase):
|
||||
home / ".local/share/pi-dictate"
|
||||
),
|
||||
}
|
||||
command = [str(SCRIPT), *arguments, "--dry-run"]
|
||||
if not any(action in arguments for action in ("uninstall", "check")):
|
||||
command.extend(("--model-source", str(model), "--model-sha256", hashlib.sha256(model.read_bytes()).hexdigest()))
|
||||
return subprocess.run(
|
||||
[str(SCRIPT), *arguments, "--dry-run", "--model-source", str(model)],
|
||||
command,
|
||||
env=environment,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
@@ -47,7 +51,9 @@ class InstallerTests(unittest.TestCase):
|
||||
self.assertNotIn("ln -s", result.stdout)
|
||||
self.assertIn(".nemo.install.", result.stdout)
|
||||
self.assertIn("mv -f", result.stdout)
|
||||
self.assertIn("uv venv --relocatable", result.stdout)
|
||||
self.assertIn("uv sync --frozen --no-dev --no-editable", result.stdout)
|
||||
self.assertIn("--reinstall-package pi-dictate-service", result.stdout)
|
||||
self.assertIn("Would install pi-dictate", result.stdout)
|
||||
self.assertFalse((home / ".local/share/pi-dictate").exists())
|
||||
|
||||
@@ -87,6 +93,25 @@ class InstallerTests(unittest.TestCase):
|
||||
"[Socket]\nListenStream=/tmp/unrelated.sock\n",
|
||||
)
|
||||
|
||||
def test_uninstall_refuses_a_modified_managed_unit(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
home = Path(directory)
|
||||
model = home / "model.nemo"
|
||||
model.write_bytes(b"model")
|
||||
unit = home / ".config/systemd/user/pi-dictate.socket"
|
||||
unit.parent.mkdir(parents=True)
|
||||
unit.write_text(
|
||||
"# Managed by pi-dictate install.sh\n[Socket]\nListenStream=/tmp/tampered.sock\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
result = self.run_installer(home, model, "uninstall")
|
||||
|
||||
self.assertEqual(result.returncode, 1)
|
||||
self.assertIn("unmanaged systemd unit", result.stderr)
|
||||
self.assertNotIn("systemctl --user disable", result.stdout)
|
||||
self.assertTrue(unit.exists())
|
||||
|
||||
def test_reinstall_preserves_an_existing_host_dictionary(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
home = Path(directory)
|
||||
|
||||
Reference in New Issue
Block a user