first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import unittest
|
||||
|
||||
from app.tzsp import TZSPError, decode_tzsp
|
||||
|
||||
|
||||
class TZSPTests(unittest.TestCase):
|
||||
def test_decodes_ethernet_frame(self):
|
||||
frame = b"\xaa" * 60
|
||||
packet = decode_tzsp(b"\x01\x00\x00\x01\x01" + frame)
|
||||
self.assertEqual(packet.encapsulation, 1)
|
||||
self.assertEqual(packet.frame, frame)
|
||||
|
||||
def test_skips_tags(self):
|
||||
frame = b"\xbb" * 60
|
||||
data = b"\x01\x00\x00\x01" + b"\x0a\x02\x12\x34" + b"\x00" + b"\x01" + frame
|
||||
packet = decode_tzsp(data)
|
||||
self.assertEqual(packet.frame, frame)
|
||||
|
||||
def test_rejects_missing_end_tag(self):
|
||||
with self.assertRaises(TZSPError):
|
||||
decode_tzsp(b"\x01\x00\x00\x01\x0a\x01\xff")
|
||||
|
||||
def test_rejects_non_packet_type(self):
|
||||
with self.assertRaises(TZSPError):
|
||||
decode_tzsp(b"\x01\x03\x00\x01\x01\x00")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user