tests: added pack and unpack test
authorRobin Krens <robin@robinkrens.nl>
Sat, 10 Feb 2024 13:53:41 +0000 (14:53 +0100)
committerRobin Krens <robin@robinkrens.nl>
Sat, 10 Feb 2024 13:53:41 +0000 (14:53 +0100)
pytest.ini [new file with mode: 0644]
tests/test_parse.py

diff --git a/pytest.ini b/pytest.ini
new file mode 100644 (file)
index 0000000..8114205
--- /dev/null
@@ -0,0 +1,2 @@
+[pytest]
+addopts = -vv
index df324bf..2aedd5c 100644 (file)
@@ -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']