Files
order-bak/tests/test_config.py
2026-04-21 15:05:55 +08:00

43 lines
1.3 KiB
Python

from pathlib import Path
from order_bak.config import load_config
def test_load_config_defaults(tmp_path):
config_path = tmp_path / "config.toml"
config_path.write_text(
'[azure]\nconnection_string = "conn_str_val"\n'
)
cfg = load_config(config_path)
assert cfg.azure_connection_string == "conn_str_val"
assert cfg.scan_page_size == 500
assert cfg.scan_delay_ms == 200
assert cfg.scan_dir == Path("./scan")
assert cfg.delete_batch_size == 100
assert cfg.delete_delay_ms == 300
def test_load_config_custom_values(tmp_path):
config_path = tmp_path / "config.toml"
config_path.write_text(
'[azure]\nconnection_string = "conn_str_val"\n'
"[scan]\npage_size = 1000\ndelay_ms = 500\nscan_dir = \"/data/scan\"\n"
"[delete]\nbatch_size = 50\ndelay_ms = 100\n"
)
cfg = load_config(config_path)
assert cfg.scan_page_size == 1000
assert cfg.scan_delay_ms == 500
assert cfg.scan_dir == Path("/data/scan")
assert cfg.delete_batch_size == 50
assert cfg.delete_delay_ms == 100
def test_load_config_missing_azure_raises(tmp_path):
config_path = tmp_path / "config.toml"
config_path.write_text("[scan]\npage_size = 100\n")
try:
load_config(config_path)
assert False, "should have raised"
except SystemExit:
pass