refactor
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
from hbd.proto import dicttos, stodict, oldmtodict
|
||||
|
||||
|
||||
def test_dicttos_and_stodict_uncompressed():
|
||||
msg = dicttos("HTB", {"name": "host.example", "interval": 10})
|
||||
d = stodict(msg)
|
||||
assert d["ID"].startswith("HTB")
|
||||
assert d["name"] == "host.example"
|
||||
assert d["interval"] == 10
|
||||
|
||||
|
||||
def test_dicttos_and_stodict_compressed():
|
||||
msg = dicttos("ACK", {"time": 12345}, compress=True)
|
||||
d = stodict(msg)
|
||||
# for compressed the original code included the colon in ID slice; ensure no crash
|
||||
assert "ID" in d
|
||||
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user