def test_reads_header_from_stream(self): """Reads FrameHeader from a bytes stream""" # Arrange frame_id = b'PRIV' size = b'\x00\x00\x00\xFF' flags = b'\x00\x00' stream = BytesIO(frame_id + size + flags) # Act header = FrameHeader.read(stream) # Assert self.assertEqual(header.frame_size, 255) self.assertEqual(header.flags, FrameHeader.Flags(0)) self.assertEqual(header.identifier, "PRIV")
def test_reads_header_if_size_bigger_than_zero(self): """Reads FrameHeader as long as size is present""" # Arrange frame_id = b'\x00\x00\x00\x00' frame_size = b'\x00\x00\x00\x01' flags = b'\x00\x00' stream = BytesIO(frame_id + frame_size + flags) # Act header = FrameHeader.read(stream) # Assert self.assertEqual(header.frame_size, 1) self.assertEqual(header.identifier, frame_id.decode("latin1")) self.assertEqual(header.flags, FrameHeader.Flags(0))