Since the built-in defaults were seeded into threshold_configs, the legacy top-level thresholds: format was silently ignored. get_thresholds_for_host now uses it whenever it was configured. Tests: point imports at hbd.server/hbd.common, rewrite the DNS worker, proto, datagram and threshold tests for the current API, add pytest-asyncio to the dev extras and set testpaths so a bare pytest runs cleanly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
648 B
Python
25 lines
648 B
Python
from hbd.common.proto import dicttos, stodict, oldmtodict
|
|
|
|
|
|
def test_dicttos_and_stodict_roundtrip():
|
|
msg = dicttos("HTB", {"name": "host.example", "interval": 10})
|
|
assert msg.startswith(b"!HTB:")
|
|
d = stodict(msg)
|
|
assert d["ID"] == "HTB"
|
|
assert d["name"] == "host.example"
|
|
assert d["interval"] == 10
|
|
|
|
|
|
def test_dicttos_and_stodict_ack():
|
|
d = stodict(dicttos("ACK", {"time": 12345}))
|
|
assert d["ID"] == "ACK"
|
|
assert d["time"] == 12345
|
|
|
|
|
|
def test_oldmtodict():
|
|
msg = b"name=foo;interval=5"
|
|
d = oldmtodict(msg)
|
|
assert d["ID"].startswith("HTB")
|
|
assert d["name"] == "foo"
|
|
assert d["interval"] == 5
|