fix: code review batch 2 — multi-channel, thread safety, DSP reset, MIDI, hotspot, NAM, docs/CI, code quality
CI / test (push) Has been cancelled

This commit is contained in:
2026-06-17 22:38:24 -04:00
parent c65e4816c4
commit 2558306e78
23 changed files with 631 additions and 125 deletions
+40 -1
View File
@@ -29,6 +29,7 @@ from src.system.network import (
hotspot_status,
hotspot_enable,
hotspot_disable,
get_hotspot_password,
_has_nmcli,
)
@@ -320,4 +321,42 @@ def test_hotspot_disable_failure(mock_subprocess):
"""hotspot_disable returns error on script failure."""
mock_subprocess.return_value = MagicMock(returncode=1, stderr="Script failed")
result = hotspot_disable()
assert result["ok"] is False
assert result["ok"] is False
# ── get_hotspot_password() tests ──────────────────────────────────────────────
def test_get_hotspot_password_generates_on_first_call(tmp_path):
"""get_hotspot_password generates and persists a random password when none set."""
with patch("src.system.network.CONFIG_PATH", tmp_path / "config.yaml"):
pwd = get_hotspot_password()
assert len(pwd) >= 8
assert pwd.isalnum() # alphanumeric only
# Second call returns the same password
pwd2 = get_hotspot_password()
assert pwd == pwd2
def test_get_hotspot_password_persists(tmp_path):
"""get_hotspot_password saves the generated password to config.yaml."""
config_path = tmp_path / "config.yaml"
with patch("src.system.network.CONFIG_PATH", config_path):
pwd = get_hotspot_password()
# Verify it was written to disk
assert config_path.exists()
import yaml
cfg = yaml.safe_load(config_path.read_text())
assert cfg["hotspot"]["password"] == pwd
def test_get_hotspot_password_returns_loaded(tmp_path):
"""get_hotspot_password returns a pre-set password from config."""
config_path = tmp_path / "config.yaml"
config_path.parent.mkdir(parents=True, exist_ok=True)
import yaml
config_path.write_text(yaml.dump({"hotspot": {"password": "MyCust0mP@ss"}}))
with patch("src.system.network.CONFIG_PATH", config_path):
pwd = get_hotspot_password()
assert pwd == "MyCust0mP@ss"