From 5ef1572a84e6e6c7207ada35c0f17f2268fde26f Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Sat, 10 Feb 2024 14:53:41 +0100 Subject: [PATCH 1/1] tests: added pack and unpack test --- pytest.ini | 2 ++ tests/test_parse.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..8114205 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = -vv diff --git a/tests/test_parse.py b/tests/test_parse.py index df324bf..2aedd5c 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,4 +1,4 @@ -from flasher.flasher import calc_sum, unpack_pkt +from flasher.flasher import calc_sum, unpack_pkt, pack_pkt import pytest def test_calc_sum(): @@ -11,3 +11,8 @@ def test_unpack(): assert unpack_pkt(b'\x81\x00\x02\x12\x00\xEC\x03') == ['0x00'] assert unpack_pkt(b'\x81\x00\x02\x13\x00\xEB\x03') == ['0x00'] +def test_pack_unpack(): + assert unpack_pkt(pack_pkt(0x13, ['0x00','0x01','0x02'])) == ['0x00', '0x01', '0x02'] + assert unpack_pkt(pack_pkt(0x34, ['0x00'])) == ['0x00'] + assert unpack_pkt(pack_pkt(0x00, ['0x00'])) == ['0x00'] + assert unpack_pkt(pack_pkt(0x12, ['0x00'])) == ['0x00'] -- 2.7.4