Add more types to test

This is highlighting the problem of
https://gitlab.com/teeworlds-network/twnet_parser/-/issues/1

Every lib user that wants to use types needs to do a cast
to access the properties of messages
This commit is contained in:
ChillerDragon 2023-04-16 11:44:09 +02:00
parent 4f540fead1
commit 65cac66724

View file

@ -1,7 +1,10 @@
from twnet_parser.packet import parse7 from twnet_parser.packet import parse7, TwPacket
from twnet_parser.messages7.game.cl_call_vote import MsgClCallVote
def test_parse_7_real_call_vote(): from typing import cast
packet = parse7(b'\x02\x7e\x01\x48\x1f\x93\xd7' \
def test_parse_7_real_call_vote() -> None:
packet: TwPacket = parse7(b'\x02\x7e\x01\x48\x1f\x93\xd7' \
b'\x40\x10\x0a' \ b'\x40\x10\x0a' \
b'\x80\x01' \ b'\x80\x01' \
b'\x6f\x70\x74\x69\x6f\x6e\x00' \ b'\x6f\x70\x74\x69\x6f\x6e\x00' \
@ -20,11 +23,11 @@ def test_parse_7_real_call_vote():
assert len(packet.messages) == 1 assert len(packet.messages) == 1
msg = packet.messages[0] msg: MsgClCallVote = cast(MsgClCallVote, packet.messages[0])
assert msg.message_name == 'cl_call_vote' assert msg.message_name == 'cl_call_vote'
assert msg.type == 'option' assert msg.type == 'option'
assert msg.value == 'test' assert msg.value == 'test'
assert msg.reason == '' assert msg.reason == ''
assert msg.force == False assert msg.force is False