Exemplo n.º 1
0
    def test_receive_three_frames(self):
        def read_func():
            data = frame_data('test' + str(read_func.i), FRAME_DATA,
                              read_func.i)
            read_func.i += 1
            return data

        def write_func(data):
            pass

        read_func.i = 1

        hdlc_c = HDLController(read_func, write_func)
        hdlc_c.start()
        self.assertEqual(hdlc_c.get_data(), b'test1')
        self.assertEqual(hdlc_c.get_data(), b'test2')
        self.assertEqual(hdlc_c.get_data(), b'test3')
        hdlc_c.stop()
Exemplo n.º 2
0
    def test_receive_one_frame(self):
        def read_func():
            return frame_data('test', FRAME_DATA, 0)

        def write_func(data):
            write_func.data = data

        write_func.data = None

        hdlc_c = HDLController(read_func, write_func)
        hdlc_c.start()
        self.assertEqual(hdlc_c.get_data(), b'test')
        self.assertEqual(write_func.data, frame_data('', FRAME_ACK, 1))
        hdlc_c.stop()