Ejemplo n.º 1
0
 def test_invalid_dir(self):
     tmpdir = tempfile.mkdtemp(dir=u'test', prefix=u'tmp.library_types.')
     entry = backend_types._WatchListEntry(os.path.join(tmpdir, "invalid-directory"), False, None)
     self.assertFalse(entry.is_valid())
     self.assertIsInstance(entry.get_new_files([]), list)
     self.assertEqual(len(entry.get_new_files([])), 0)
     shutil.rmtree(tmpdir)
Ejemplo n.º 2
0
    def test_invalid_dir(self):
        entry = backend_types._WatchListEntry("/root/invalid-directory", False,
                                              None)

        self.assertFalse(entry.is_valid())
        self.assertIsInstance(entry.get_new_files([]), list)
        self.assertEqual(len(entry.get_new_files([])), 0)
Ejemplo n.º 3
0
 def test_invalid_dir(self):
     tmpdir = tempfile.mkdtemp(dir=u'test', prefix=u'tmp.library_types.')
     entry = backend_types._WatchListEntry(
         os.path.join(tmpdir, "invalid-directory"), False, None)
     self.assertFalse(entry.is_valid())
     self.assertIsInstance(entry.get_new_files([]), list)
     self.assertEqual(len(entry.get_new_files([])), 0)
     shutil.rmtree(tmpdir)
Ejemplo n.º 4
0
    def test_valid_dir(self):
        directory = unicode(os.path.abspath('test/files/archives'))
        available = [os.path.join(directory, u'01-ZIP-Normal.zip'),
                     os.path.join(directory, u'02-TAR-Normal.tar')]
        others = [os.path.join(directory, u'03-RAR-Normal.rar'),
                  os.path.join(directory, u'04-7Z-Normal.7z')]

        entry = backend_types._WatchListEntry(directory, None)
        new_files = entry.get_new_files(available)
        new_files.sort()

        self.assertIsInstance(new_files, list)
        self.assertEqual(new_files, others)
Ejemplo n.º 5
0
    def get_selected_watchlist_entry(self):
        """ Returns the selected watchlist entry, or C{None} if no
        item is selected. """
        selection = self._treeview.get_selection()

        model, iter = selection.get_selected()
        if iter is not None:
            path = model.get_value(iter, COL_DIRECTORY)
            collection_id = model.get_value(iter, COL_COLLECTION_ID)
            collection = self.library.backend.get_collection_by_id(collection_id)

            return backend_types._WatchListEntry(path, collection)
        else:
            return None
Ejemplo n.º 6
0
    def get_selected_watchlist_entry(self):
        """ Returns the selected watchlist entry, or C{None} if no
        item is selected. """
        selection = self._treeview.get_selection()

        model, iter = selection.get_selected()
        if iter is not None:
            path = model.get_value(iter, COL_DIRECTORY)
            collection_id = model.get_value(iter, COL_COLLECTION_ID)
            collection = self.library.backend.get_collection_by_id(
                collection_id)

            return backend_types._WatchListEntry(path, collection)
        else:
            return None
Ejemplo n.º 7
0
    def test_valid_dir(self):
        directory = unicode(os.path.abspath('test/files/archives'))
        available = [
            os.path.join(directory, u'01-ZIP-Normal.zip'),
            os.path.join(directory, u'02-TAR-Normal.tar')
        ]
        others = [
            os.path.join(directory, u'03-RAR-Normal.rar'),
            os.path.join(directory, u'04-7Z-Normal.7z')
        ]

        entry = backend_types._WatchListEntry(directory, None)
        new_files = entry.get_new_files(available)
        new_files.sort()

        self.assertIsInstance(new_files, list)
        self.assertEqual(new_files, others)
Ejemplo n.º 8
0
    def test_valid_dir(self):
        tmpdir = os.path.abspath(tempfile.mkdtemp(dir=u'test', prefix=u'tmp.library_types.'))
        directory = unicode(os.path.abspath('test/files/archives'))
        available = [u'01-ZIP-Normal.zip', u'02-TAR-Normal.tar']
        others = [u'03-RAR-Normal.rar', u'04-7Z-Normal.7z']
        for entry_list in (available, others):
            for n, entry in enumerate(entry_list):
                src = os.path.join(directory, entry)
                dst = os.path.join(tmpdir, entry)
                shutil.copy(src, dst)
                entry_list[n] = dst

        entry = backend_types._WatchListEntry(tmpdir, True, None)
        new_files = entry.get_new_files(available)
        new_files.sort()

        self.assertIsInstance(new_files, list)
        self.assertEqual(new_files, others)

        shutil.rmtree(tmpdir)
Ejemplo n.º 9
0
    def test_valid_dir(self):
        tmpdir = os.path.abspath(
            tempfile.mkdtemp(dir=u'test', prefix=u'tmp.library_types.'))
        directory = unicode(os.path.abspath('test/files/archives'))
        available = [u'01-ZIP-Normal.zip', u'02-TAR-Normal.tar']
        others = [u'03-RAR-Normal.rar', u'04-7Z-Normal.7z']
        for entry_list in (available, others):
            for n, entry in enumerate(entry_list):
                src = os.path.join(directory, entry)
                dst = os.path.join(tmpdir, entry)
                shutil.copy(src, dst)
                entry_list[n] = dst

        entry = backend_types._WatchListEntry(tmpdir, True, None)
        new_files = entry.get_new_files(available)
        new_files.sort()

        self.assertIsInstance(new_files, list)
        self.assertEqual(new_files, others)

        shutil.rmtree(tmpdir)
Ejemplo n.º 10
0
    def test_invalid_dir(self):
        entry = backend_types._WatchListEntry("/root/invalid-directory", None)

        self.assertFalse(entry.is_valid())
        self.assertIsInstance(entry.get_new_files([]), list)
        self.assertEqual(len(entry.get_new_files([])), 0)