예제 #1
0
    def test_redraw_file_win(self):
        # Setup
        self.packet_list.packets = [
            Packet(type=FILE,
                   name='testfile.txt',
                   assembly_pt_list=5 * [b'a'],
                   packets=10,
                   size="100.0KB",
                   contact=create_contact('Bob')),
            Packet(type=FILE,
                   name='testfile2.txt',
                   assembly_pt_list=7 * [b'a'],
                   packets=100,
                   size="15.0KB",
                   contact=create_contact('Charlie'))
        ]

        # Test
        window = self.create_window(WIN_TYPE_FILE)
        self.assertPrints(
            f"""\

File name         Size        Sender      Complete    
────────────────────────────────────────────────────────────────────────────────
testfile.txt      100.0KB     Bob         50.00%      
testfile2.txt     15.0KB      Charlie     7.00%       

{6*(CURSOR_UP_ONE_LINE+CLEAR_ENTIRE_LINE)}""", window.redraw_file_win)
예제 #2
0
    def test_select_rx_file_window(self):
        # Setup
        self.window_list.windows = [
            self.create_window(g)
            for g in ['test_group', 'test_group2', WIN_TYPE_FILE]
        ]
        tg_win = self.window_list.windows[0]
        tg_win.is_active = True
        self.window_list.active_win = tg_win
        self.packet_list.packets = [
            Packet(type=FILE,
                   name='testfile.txt',
                   assembly_pt_list=5 * [b'a'],
                   packets=10,
                   size="100.0KB",
                   contact=create_contact('Bob'))
        ]

        # Test
        self.assertPrints(
            f"""\

File name        Size        Sender     Complete    
────────────────────────────────────────────────────────────────────────────────
testfile.txt     100.0KB     Bob        50.00%      

{5*(CURSOR_UP_ONE_LINE+CLEAR_ENTIRE_LINE)}""",
            self.window_list.select_rx_window, WIN_TYPE_FILE)

        self.assertFalse(tg_win.is_active)
        self.assertTrue(self.window_list.get_window(WIN_TYPE_FILE).is_active)
예제 #3
0
    def test_class(self):
        # Setup
        packet_list = PacketList()
        file_window = FileWindow('*****@*****.**', packet_list)

        # Test
        self.assertIsNone(file_window.redraw())

        packet_list.packet_l = [Packet(assembly_pt_list=[5*b'a'],
                                       type='file',
                                       f_size=b'30kb',
                                       contact=create_contact(nick='Alice'),
                                       f_packets=20)]

        file_window = FileWindow('*****@*****.**', packet_list)
        self.assertIsNone(file_window.redraw())