diff options
| author | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-17 15:05:36 +0100 |
|---|---|---|
| committer | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-17 15:05:36 +0100 |
| commit | aff435a0fb3a56b1d7b738c7dede363440884b3a (patch) | |
| tree | 07acb41d37760aa169ee42dbeb69da3621cc7489 /tests/test_canonical_record.py | |
| parent | a7f74c1fa4b89c5829f5896842eb7248c820704c (diff) | |
| download | dotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.tar.gz dotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.tar.bz2 dotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.zip | |
Add the Canonical laptop profile and setup workflows
Diffstat (limited to 'tests/test_canonical_record.py')
| -rw-r--r-- | tests/test_canonical_record.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_canonical_record.py b/tests/test_canonical_record.py new file mode 100644 index 0000000..cfc9faf --- /dev/null +++ b/tests/test_canonical_record.py @@ -0,0 +1,51 @@ +import importlib.util +import tempfile +import unittest +from pathlib import Path +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location( + "record", ROOT / "dot_local/lib/dotfiles/record.py" +) +assert SPEC and SPEC.loader +record = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(record) + + +class RecorderTests(unittest.TestCase): + def test_start_is_idempotent(self): + with ( + patch.object(record, "active", return_value=True), + patch.object(record.subprocess, "run") as run, + ): + record.start(Path("/unused")) + run.assert_not_called() + + def test_stop_before_portal_selection_stops_only_owned_service(self): + with ( + tempfile.TemporaryDirectory() as directory, + patch.object(record, "active", return_value=True), + patch.object(record.subprocess, "run") as run, + ): + record.stop(Path(directory)) + run.assert_called_once_with( + ["systemctl", "--user", "stop", "dotfiles-record.service"], check=True + ) + + def test_stop_uses_recorder_ipc_when_available(self): + with tempfile.TemporaryDirectory() as directory: + runtime = Path(directory) + (runtime / "control.sock").touch() + with ( + patch.object(record, "active", return_value=True), + patch.object(record.subprocess, "run") as run, + ): + record.stop(runtime) + command = run.call_args.args[0] + self.assertIn("--command=gsr-cli", command) + self.assertEqual(command[-1], "stop") + + +if __name__ == "__main__": + unittest.main() |
