<s> import unittest <EOL> from hbmqtt . mqtt . pubrec import PubrecPacket , PacketIdVariableHeader <EOL> from hbmqtt . adapters import BufferReader <EOL> from hbmqtt . codecs import * <EOL> class PubrecPacketTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . loop = asyncio . new_event_loop ( ) <EOL> def test_from_stream ( self ) : <EOL> data = b'<STR_LIT>' <EOL> stream = BufferReader ( data ) <EOL> message = self . loop . run_until_complete ( PubrecPacket . from_stream ( stream ) ) <EOL> self . assertEqual ( message . variable_header . packet_id , <NUM_LIT:10> ) <EOL> def test_to_bytes ( self ) : <EOL> variable_header = PacketIdVariableHeader ( <NUM_LIT:10> ) <EOL> publish = PubrecPacket ( variable_header = variable_header ) <EOL> out = publish . to_bytes ( ) <EOL> self . assertEqual ( out , b'<STR_LIT>' ) </s>
