32 lines
726 B
Python
32 lines
726 B
Python
from pathlib import Path
|
|
|
|
from line_laser_modbus.config import AppConfig
|
|
|
|
|
|
def test_app_config_reads_serial_and_polling_sections(tmp_path: Path) -> None:
|
|
config_file = tmp_path / "config.toml"
|
|
config_file.write_text(
|
|
"""
|
|
[serial]
|
|
port = "COM9"
|
|
slave_id = 8
|
|
|
|
[polling]
|
|
interval_seconds = 0.01
|
|
max_timeouts = 5
|
|
""".strip(),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
config = AppConfig.from_toml(config_file)
|
|
|
|
assert config.serial.port == "COM9"
|
|
assert config.polling.interval_seconds == 0.01
|
|
assert config.polling.max_timeouts == 5
|
|
|
|
|
|
def test_default_config_matches_v12_timing() -> None:
|
|
config = AppConfig()
|
|
assert config.serial.timeout == 0.15
|
|
assert config.polling.interval_seconds == 0.05
|