47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""The host launcher selects one model while retaining the CPU default."""
|
|
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
LAUNCHER = Path(__file__).resolve().parents[1] / "run_fertigungski.sh"
|
|
|
|
|
|
def test_fertigungski_rejects_alternate_protocol_model():
|
|
result = subprocess.run(
|
|
["bash", str(LAUNCHER)],
|
|
env={**os.environ, "MKA_PROTOCOL_MODEL": "other:model"},
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
assert result.returncode == 1
|
|
assert "requires MKA_PROTOCOL_MODEL=qwen3.8:27b" in result.stderr
|
|
|
|
|
|
def test_fertigungski_exports_fixed_model_and_cpu_default(tmp_path):
|
|
launcher = tmp_path / "run_fertigungski.sh"
|
|
launcher.write_bytes(LAUNCHER.read_bytes())
|
|
streamlit = tmp_path / ".venv/bin/streamlit"
|
|
streamlit.parent.mkdir(parents=True)
|
|
streamlit.write_text(
|
|
'#!/bin/bash\nprintf "%s %s\\n" "$MKA_PROTOCOL_MODEL" "$MKA_WHISPER_BACKEND"\n'
|
|
)
|
|
streamlit.chmod(0o755)
|
|
executable = tmp_path / "whisper-cli"
|
|
executable.write_text("#!/bin/bash\nexit 0\n")
|
|
executable.chmod(0o755)
|
|
model = tmp_path / "model.bin"
|
|
model.write_bytes(b"model")
|
|
environment = {key: value for key, value in os.environ.items() if not key.startswith("MKA_")}
|
|
environment.update(MKA_WHISPER_EXECUTABLE=str(executable), MKA_WHISPER_MODEL=str(model))
|
|
result = subprocess.run(
|
|
["bash", str(launcher)],
|
|
env=environment,
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
assert result.returncode == 0
|
|
assert result.stdout.strip() == "qwen3.8:27b cpu"
|