Files
computer-playbook/tests/unit/cli/core/test_run.py
T
kevinveenbirkenbach 5acce545e1 refactor(cli): remove sound, alarm and server-type flags
Drop the sound/alarm subsystem and deprecated CLI flags.

* Remove --sound, --no-signal and --alarm-timeout
* Remove server-type flag (-T / TEST_DEPLOY_TYPE)
* Delete sound-related modules
* Simplify RunConfig and runner error handling
* Update help output, scripts and tests
* Remove optional audio extras from pyproject.toml

https://chatgpt.com/share/698b74f1-0c0c-800f-98c4-183697d6a2a0
2026-02-10 19:10:37 +01:00

48 lines
1.4 KiB
Python

import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
from cli.core.run import RunConfig, open_log_file, run_command_once
class TestRun(unittest.TestCase):
def test_open_log_file_creates_in_given_dir(self):
with tempfile.TemporaryDirectory() as td:
log_dir = Path(td) / "logs"
f, path = open_log_file(log_dir)
try:
self.assertTrue(path.exists())
self.assertIn(log_dir, path.parents)
finally:
f.close()
@patch("cli.core.run.subprocess.Popen")
def test_run_command_once_nonzero_exits(self, mock_popen):
proc = unittest.mock.Mock()
proc.wait.return_value = None
proc.returncode = 2
mock_popen.return_value = proc
cfg = RunConfig(log_enabled=False)
with self.assertRaises(SystemExit):
run_command_once(["python", "-c", "print(1)"], cfg, log_file=None)
@patch("cli.core.run.subprocess.Popen")
def test_run_command_once_success_returns_true(self, mock_popen):
proc = unittest.mock.Mock()
proc.wait.return_value = None
proc.returncode = 0
mock_popen.return_value = proc
cfg = RunConfig(log_enabled=False)
ok = run_command_once(["python", "-c", "print(1)"], cfg, log_file=None)
self.assertTrue(ok)
if __name__ == "__main__":
unittest.main()