Files
sh4un 3cf9ea5d22 Refactor test and configuration files for improved readability and consistency
- Updated test_protocol.py to maintain consistent formatting and structure.
- Adjusted tmp_no_default.ini to use consistent line endings.
- Reformatted tmp_run_load.py and tmp_test_config.py for improved readability.
2026-04-17 14:36:27 -04:00

21 lines
622 B
Python

from ammb.protocol import JsonNewlineProtocol, get_serial_protocol_handler
def test_json_newline_encode():
handler = JsonNewlineProtocol()
data = {"key": "value"}
encoded = handler.encode(data)
assert encoded == b'{"key": "value"}\n'
def test_factory_function():
handler = get_serial_protocol_handler("json_newline")
assert isinstance(handler, JsonNewlineProtocol)
def test_raw_serial_handler():
handler = get_serial_protocol_handler("raw_serial")
raw_data = b"\x01\x02\x03"
decoded = handler.decode(raw_data)
assert decoded["payload"] == "MC_BIN: 010203"