config: add gain and certificate fields

This commit is contained in:
Username
2026-02-24 14:13:18 +01:00
parent 0856ab3c55
commit eb98165370
2 changed files with 29 additions and 1 deletions

View File

@@ -16,6 +16,8 @@ class ServerConfig:
username: str = "tuimble-user"
password: str = ""
channel: str = ""
certfile: str = ""
keyfile: str = ""
@dataclass
@@ -24,6 +26,8 @@ class AudioConfig:
output_device: int | None = None
sample_rate: int = 48000
frame_size: int = 960 # 20ms at 48kHz
input_gain: float = 1.0
output_gain: float = 1.0
@dataclass

View File

@@ -1,6 +1,6 @@
"""Tests for configuration module."""
from tuimble.config import Config, PttConfig, ServerConfig
from tuimble.config import AudioConfig, Config, PttConfig, ServerConfig
def test_default_config():
@@ -21,3 +21,27 @@ def test_ptt_config_defaults():
ptt = PttConfig()
assert ptt.key == "f4"
assert ptt.backend == "auto"
def test_audio_gain_defaults():
acfg = AudioConfig()
assert acfg.input_gain == 1.0
assert acfg.output_gain == 1.0
def test_audio_gain_custom():
acfg = AudioConfig(input_gain=0.5, output_gain=1.5)
assert acfg.input_gain == 0.5
assert acfg.output_gain == 1.5
def test_server_cert_defaults():
srv = ServerConfig()
assert srv.certfile == ""
assert srv.keyfile == ""
def test_server_cert_custom():
srv = ServerConfig(certfile="/path/cert.pem", keyfile="/path/key.pem")
assert srv.certfile == "/path/cert.pem"
assert srv.keyfile == "/path/key.pem"