fix: code review batch 2 — multi-channel, thread safety, DSP reset, MIDI, hotspot, NAM, docs/CI, code quality
CI / test (push) Has been cancelled
CI / test (push) Has been cancelled
This commit is contained in:
+40
-1
@@ -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"
|
||||
@@ -21,7 +21,7 @@ for p in [SRC, PROJECT_ROOT]:
|
||||
if str(p) not in sys.path:
|
||||
sys.path.insert(0, str(p))
|
||||
|
||||
from src.dsp.pipeline import AudioPipeline, BLOCK_SIZE, SAMPLE_RATE
|
||||
from src.dsp.pipeline import AudioPipeline
|
||||
from src.presets.types import FXBlock, FXType, Preset
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -92,7 +92,8 @@ def client(deps, monkeypatch):
|
||||
# Mock hardware-dependent gathers so tests don't hang on bluetoothctl/nmcli
|
||||
monkeypatch.setattr(WebServer, "_gather_wifi_state", lambda self: {
|
||||
"connected": False, "ssid": None, "ip": None, "signal": 0,
|
||||
"hotspot_active": False, "hotspot_ssid": None, "hotspot_clients": 0,
|
||||
"hotspot_active": False, "hotspot_ssid": None,
|
||||
"hotspot_password": None, "hotspot_clients": 0,
|
||||
})
|
||||
monkeypatch.setattr(WebServer, "_gather_bt_state", lambda self: {
|
||||
"available": False, "powered": False, "name": None,
|
||||
|
||||
Reference in New Issue
Block a user