21 lines
810 B
Python
21 lines
810 B
Python
|
|
from tamq.config import setting
|
||
|
|
|
||
|
|
|
||
|
|
def test_toml_defaults(monkeypatch, tmp_path):
|
||
|
|
config = tmp_path / "config.toml"
|
||
|
|
config.write_text("[tamq]\npurge_before='30d'\nhistory_max_size='12MB'\n")
|
||
|
|
monkeypatch.setenv("TAMQ_CONFIG", str(config))
|
||
|
|
assert setting("purge_before", "365d") == "30d"
|
||
|
|
assert setting("history_max_size", "100MB") == "12MB"
|
||
|
|
assert setting("missing", "fallback") == "fallback"
|
||
|
|
|
||
|
|
|
||
|
|
def test_delivery_interval_is_configurable(monkeypatch, tmp_path):
|
||
|
|
config = tmp_path / "config.toml"
|
||
|
|
config.write_text("[tamq]\ndelivery_poll_interval='2.5'\n")
|
||
|
|
monkeypatch.setenv("TAMQ_CONFIG", str(config))
|
||
|
|
from tamq.service import Service
|
||
|
|
from tamq.store import Store
|
||
|
|
service = Service(store=Store(tmp_path / "state.sqlite3"))
|
||
|
|
assert service.poll_interval == 2.5
|