Ejemplo n.º 1
0
class TorrentviewTestCase(unittest.TestCase):

    def setUp(self):  # NOQA
        pass

    def tearDown(self):  # NOQA
        pass

    def test_torrentview_columns(self):
        self.mainwindow = MainWindow()
        self.torrentview = TorrentView()
        self.torrentdetails = TorrentDetails()
        self.menubar = MenuBar()

        default_column_index = ['filter', 'torrent_id', 'dirty', '#', 'Name', 'Size', 'Downloaded', 'Uploaded', 'Progress', 'Seeders', 'Peers', 'Seeders/Peers', 'Down Speed', 'Up Speed', 'Down Limit', 'Up Limit', 'ETA', 'Ratio', 'Avail', 'Added', 'Tracker', 'Save Path']
        default_liststore_columns = [bool, str, bool, int, str, str, gobject.TYPE_UINT64, gobject.TYPE_UINT64, gobject.TYPE_UINT64, float, str, int, int, int, int, float, float, float, float, float, int, float, float, float, str, str, str]

        self.assertEquals(self.torrentview.column_index, default_column_index)
        self.assertEquals(self.torrentview.liststore_columns, default_liststore_columns)

        self.assertEquals(self.torrentview.columns["Save Path"].column_indices, [26])

        # Add a text column
        test_col = "Test column"
        self.torrentview.add_text_column(test_col, status_field=["label"])
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col)
        self.assertEquals(self.torrentview.columns[test_col].column_indices, [27])

        # Add a second text column
        test_col2 = "Test column2"
        self.torrentview.add_text_column(test_col2, status_field=["label2"])
        self.assertEquals(len(self.torrentview.liststore_columns), 29)
        self.assertEquals(len(self.torrentview.column_index), 24)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices, [28])

        # Remove column
        self.torrentview.remove_column(test_col)
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices, [27])

        # Add a column with multiple column types
        test_col3 = "Test column3"
        self.torrentview.add_progress_column(test_col3, status_field=["progress", "label3"], col_types=[float, str])
        self.assertEquals(len(self.torrentview.liststore_columns), 30)
        self.assertEquals(len(self.torrentview.column_index), 24)
        self.assertEquals(self.torrentview.column_index[-1], test_col3)
        self.assertEquals(self.torrentview.columns[test_col3].column_indices, [28, 29])

        # Remove multiple column-types column
        self.torrentview.remove_column(test_col3)
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices, [27])
Ejemplo n.º 2
0
class TorrentviewTestCase(BaseTestCase):

    default_column_index = ['filter', 'torrent_id', 'dirty', '#',
                            'Name',
                            'Size', 'Downloaded', 'Uploaded', 'Remaining',
                            'Progress',
                            'Seeds', 'Peers', 'Seeds:Peers',
                            'Down Speed', 'Up Speed', 'Down Limit', 'Up Limit',
                            'ETA', 'Ratio', 'Avail',
                            'Added', 'Completed', 'Complete Seen',
                            'Tracker', 'Download Folder', 'Owner', 'Shared']
    default_liststore_columns = [bool, str, bool, int,
                                 str, str,  # Name
                                 TYPE_UINT64, TYPE_UINT64, TYPE_UINT64, TYPE_UINT64,
                                 float, str,  # Progress
                                 int, int, int, int, float,  # Seeds, Peers
                                 int, int, float, float,
                                 int, float, float,  # ETA, Ratio, Avail
                                 int, int, int,
                                 str, str,  # Tracker
                                 str, str,
                                 bool]  # shared

    def set_up(self):
        if libs_available is False:
            raise unittest.SkipTest('GTKUI dependencies not available')

        common.set_tmp_config_dir()
        # MainWindow loads this config file, so lets make sure it contains the defaults
        ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)
        self.mainwindow = MainWindow()
        self.torrentview = TorrentView()
        self.torrentdetails = TorrentDetails()
        self.menubar = MenuBar()

    def tear_down(self):
        return component.shutdown()

    def test_torrentview_columns(self):

        self.assertEqual(self.torrentview.column_index, TorrentviewTestCase.default_column_index)
        self.assertEqual(self.torrentview.liststore_columns, TorrentviewTestCase.default_liststore_columns)
        self.assertEqual(self.torrentview.columns['Download Folder'].column_indices, [29])

    def test_add_column(self):

        # Add a text column
        test_col = 'Test column'
        self.torrentview.add_text_column(test_col, status_field=['label'])
        self.assertEqual(len(self.torrentview.liststore_columns),
                         len(TorrentviewTestCase.default_liststore_columns) + 1)
        self.assertEqual(len(self.torrentview.column_index),
                         len(TorrentviewTestCase.default_column_index) + 1)
        self.assertEqual(self.torrentview.column_index[-1], test_col)
        self.assertEqual(self.torrentview.columns[test_col].column_indices, [32])

    def test_add_columns(self):

        # Add a text column
        test_col = 'Test column'
        self.torrentview.add_text_column(test_col, status_field=['label'])

        # Add a second text column
        test_col2 = 'Test column2'
        self.torrentview.add_text_column(test_col2, status_field=['label2'])

        self.assertEqual(len(self.torrentview.liststore_columns),
                         len(TorrentviewTestCase.default_liststore_columns) + 2)
        self.assertEqual(len(self.torrentview.column_index),
                         len(TorrentviewTestCase.default_column_index) + 2)
        # test_col
        self.assertEqual(self.torrentview.column_index[-2], test_col)
        self.assertEqual(self.torrentview.columns[test_col].column_indices, [32])

        # test_col2
        self.assertEqual(self.torrentview.column_index[-1], test_col2)
        self.assertEqual(self.torrentview.columns[test_col2].column_indices, [33])

    def test_remove_column(self):

        # Add and remove text column
        test_col = 'Test column'
        self.torrentview.add_text_column(test_col, status_field=['label'])
        self.torrentview.remove_column(test_col)

        self.assertEqual(len(self.torrentview.liststore_columns), len(TorrentviewTestCase.default_liststore_columns))
        self.assertEqual(len(self.torrentview.column_index), len(TorrentviewTestCase.default_column_index))
        self.assertEqual(self.torrentview.column_index[-1], TorrentviewTestCase.default_column_index[-1])
        self.assertEqual(self.torrentview.columns[TorrentviewTestCase.default_column_index[-1]].column_indices, [31])

    def test_remove_columns(self):

        # Add two columns
        test_col = 'Test column'
        self.torrentview.add_text_column(test_col, status_field=['label'])
        test_col2 = 'Test column2'
        self.torrentview.add_text_column(test_col2, status_field=['label2'])

        # Remove test_col
        self.torrentview.remove_column(test_col)
        self.assertEqual(len(self.torrentview.liststore_columns),
                         len(TorrentviewTestCase.default_liststore_columns) + 1)
        self.assertEqual(len(self.torrentview.column_index),
                         len(TorrentviewTestCase.default_column_index) + 1)
        self.assertEqual(self.torrentview.column_index[-1], test_col2)
        self.assertEqual(self.torrentview.columns[test_col2].column_indices, [32])

        # Remove test_col2
        self.torrentview.remove_column(test_col2)
        self.assertEqual(len(self.torrentview.liststore_columns), len(TorrentviewTestCase.default_liststore_columns))
        self.assertEqual(len(self.torrentview.column_index), len(TorrentviewTestCase.default_column_index))
        self.assertEqual(self.torrentview.column_index[-1], TorrentviewTestCase.default_column_index[-1])
        self.assertEqual(self.torrentview.columns[TorrentviewTestCase.default_column_index[-1]].column_indices, [31])

    def test_add_remove_column_multiple_types(self):

        # Add a column with multiple column types
        test_col3 = 'Test column3'
        self.torrentview.add_progress_column(test_col3, status_field=['progress', 'label3'], col_types=[float, str])
        self.assertEqual(len(self.torrentview.liststore_columns),
                         len(TorrentviewTestCase.default_liststore_columns) + 2)
        self.assertEqual(len(self.torrentview.column_index),
                         len(TorrentviewTestCase.default_column_index) + 1)
        self.assertEqual(self.torrentview.column_index[-1], test_col3)
        self.assertEqual(self.torrentview.columns[test_col3].column_indices, [32, 33])

        # Remove multiple column-types column
        self.torrentview.remove_column(test_col3)

        self.assertEqual(len(self.torrentview.liststore_columns), len(TorrentviewTestCase.default_liststore_columns))
        self.assertEqual(len(self.torrentview.column_index), len(TorrentviewTestCase.default_column_index))
        self.assertEqual(self.torrentview.column_index[-1], TorrentviewTestCase.default_column_index[-1])
        self.assertEqual(self.torrentview.columns[TorrentviewTestCase.default_column_index[-1]].column_indices, [31])
Ejemplo n.º 3
0
class TorrentviewTestCase(unittest.TestCase):
    def setUp(self):  # NOQA
        pass

    def tearDown(self):  # NOQA
        pass

    def test_torrentview_columns(self):
        self.mainwindow = MainWindow()
        self.torrentview = TorrentView()
        self.torrentdetails = TorrentDetails()
        self.menubar = MenuBar()

        default_column_index = [
            'filter', 'torrent_id', 'dirty', '#', 'Name', 'Size', 'Downloaded',
            'Uploaded', 'Progress', 'Seeders', 'Peers', 'Seeders/Peers',
            'Down Speed', 'Up Speed', 'Down Limit', 'Up Limit', 'ETA', 'Ratio',
            'Avail', 'Added', 'Tracker', 'Save Path'
        ]
        default_liststore_columns = [
            bool, str, bool, int, str, str, gobject.TYPE_UINT64,
            gobject.TYPE_UINT64, gobject.TYPE_UINT64, float, str, int, int,
            int, int, float, float, float, float, float, int, float, float,
            float, str, str, str
        ]

        self.assertEquals(self.torrentview.column_index, default_column_index)
        self.assertEquals(self.torrentview.liststore_columns,
                          default_liststore_columns)

        self.assertEquals(self.torrentview.columns["Save Path"].column_indices,
                          [26])

        # Add a text column
        test_col = "Test column"
        self.torrentview.add_text_column(test_col, status_field=["label"])
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col)
        self.assertEquals(self.torrentview.columns[test_col].column_indices,
                          [27])

        # Add a second text column
        test_col2 = "Test column2"
        self.torrentview.add_text_column(test_col2, status_field=["label2"])
        self.assertEquals(len(self.torrentview.liststore_columns), 29)
        self.assertEquals(len(self.torrentview.column_index), 24)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices,
                          [28])

        # Remove column
        self.torrentview.remove_column(test_col)
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices,
                          [27])

        # Add a column with multiple column types
        test_col3 = "Test column3"
        self.torrentview.add_progress_column(
            test_col3,
            status_field=["progress", "label3"],
            col_types=[float, str])
        self.assertEquals(len(self.torrentview.liststore_columns), 30)
        self.assertEquals(len(self.torrentview.column_index), 24)
        self.assertEquals(self.torrentview.column_index[-1], test_col3)
        self.assertEquals(self.torrentview.columns[test_col3].column_indices,
                          [28, 29])

        # Remove multiple column-types column
        self.torrentview.remove_column(test_col3)
        self.assertEquals(len(self.torrentview.liststore_columns), 28)
        self.assertEquals(len(self.torrentview.column_index), 23)
        self.assertEquals(self.torrentview.column_index[-1], test_col2)
        self.assertEquals(self.torrentview.columns[test_col2].column_indices,
                          [27])