twnet_parser/tests/packet_ctrl_close7_test.py
ChillerDragon c8f8ca6a21 Break api packet.parse -> packet.parse7
Rename the main `twnet_parser.packet.parse()` method.
Into more explicit `parse6()` and `parse7()`
2023-03-18 10:04:11 +01:00

23 lines
675 B
Python

from twnet_parser.packet import *
def test_parse_7_close():
packet = parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04') # 0.7 close
assert packet.version == '0.7'
assert packet.header.flags.control == True
assert packet.messages[0].name == 'close'
assert len(packet.messages) == 1
def test_parse_7_close_with_reason():
packet = parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04shutdown\x00') # 0.7 close
assert packet.version == '0.7'
assert packet.header.flags.control == True
assert packet.messages[0].name == 'close'
assert len(packet.messages) == 1
# TODO: uncomment when implemented
# assert packet.messages[0].reason == 'shutdown'