Exemplo n.º 1
0
    def setUp(self):
        super(PPPrivateTests, self).setUp()

        sickbeard.showList = [TVShow(0000), TVShow(0001)]

        self.pp = PostProcessor(test_lib.FILEPATH)
        self.show_obj = TVShow(0002)

        self.db = test_lib.db.DBConnection()
        newValueDict = {
            "tvdbid": 1002,
            "name": test_lib.SHOWNAME,
            "description": "description",
            "airdate": 1234,
            "hasnfo": 1,
            "hastbn": 1,
            "status": 404,
            "location": test_lib.FILEPATH
        }
        controlValueDict = {
            "showid": 0002,
            "season": test_lib.SEASON,
            "episode": test_lib.EPISODE
        }

        # use a custom update/insert method to get the data into the DB
        self.db.upsert("tv_episodes", newValueDict, controlValueDict)

        self.ep_obj = TVEpisode(self.show_obj, test_lib.SEASON,
                                test_lib.EPISODE, test_lib.FILEPATH)
Exemplo n.º 2
0
class ListAssociatedFiles(unittest.TestCase):
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join(u'Show Name', u'associated_files', u'random', u'recursive', u'subdir')

        file_names = [
            u'Show Name [SickRage].avi',
            u'Show Name [SickRage].srt',
            u'Show Name [SickRage].nfo',
            u'Show Name [SickRage].en.srt',
            u'Non-Associated Show [SickRage].srt',
            u'Non-Associated Show [SickRage].en.srt',
            u'Show [SickRage] Non-Associated.en.srt',
            u'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [os.path.join(u'Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor(u'Show Name')
        self.maxDiff = None

    def setUp(self):
        make_dirs(self.test_tree)
        for test_file in self.file_list:
            open(test_file, 'a').close()

    def tearDown(self):
        shutil.rmtree(u'Show Name')

    def test_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=False)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=False)
        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)
Exemplo n.º 3
0
    def test_process(self):
        show = TVShow(1, 3)
        show.name = test.SHOWNAME
        show.location = test.SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, test.SEASON, test.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        pp = PostProcessor(test.FILEPATH)
        self.assertTrue(pp.process())
Exemplo n.º 4
0
    def test_process(self):
        show = TVShow(3)
        show.name = test.SHOWNAME
        show.location = test.SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, test.SEASON, test.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        pp = PostProcessor(test.FILEPATH)
        self.assertTrue(pp.process())
Exemplo n.º 5
0
    def test_process(self):
        show = TVShow(1, 3)
        show.name = test.SHOWNAME
        show.location = test.SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, test.SEASON, test.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        addNameToCache('show name', 3)
        self.pp = PostProcessor(test.FILEPATH, process_method='move')
        self.assertTrue(self.pp.process())
Exemplo n.º 6
0
    def setUp(self):
        super(PPPrivateTests, self).setUp()

        sickbeard.showList = [TVShow(0000), TVShow(0001)]

        self.pp = PostProcessor(test.FILEPATH)
        self.show_obj = TVShow(0002)

        self.db = test.db.DBConnection()
        newValueDict = {"tvdbid": 1002,
                        "name": test.SHOWNAME,
                        "description": "description",
                        "airdate": 1234,
                        "hasnfo": 1,
                        "hastbn": 1,
                        "status": 404,
                        "location": test.FILEPATH}
        controlValueDict = {"showid": 0002,
                            "season": test.SEASON,
                            "episode": test.EPISODE}

        # use a custom update/insert method to get the data into the DB
        self.db.upsert("tv_episodes", newValueDict, controlValueDict)

        self.ep_obj = TVEpisode(self.show_obj, test.SEASON, test.EPISODE, test.FILEPATH)
Exemplo n.º 7
0
    def test_process(self):
        show = TVShow(1,3)
        show.name = test.SHOWNAME
        show.location = test.SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, test.SEASON, test.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        addNameToCache('show name', 3)
        sickbeard.PROCESS_METHOD = 'move'

        pp = PostProcessor(test.FILEPATH)
        self.assertTrue(pp.process())
Exemplo n.º 8
0
    def test_process(self):
        show_obj = TVShow(1, 3)
        show_obj.tvid = TVINFO_TVDB
        show_obj.name = test.SHOWNAME
        show_obj.location = test.SHOWDIR
        show_obj.save_to_db()

        sickbeard.showList = [show_obj]
        ep_obj = TVEpisode(show_obj, test.SEASON, test.EPISODE)
        ep_obj.name = 'some ep name'
        ep_obj.release_name = 'test setter'
        ep_obj.save_to_db()

        addNameToCache('show name', tvid=TVINFO_TVDB, prodid=3)
        sickbeard.PROCESS_METHOD = 'move'

        pp = PostProcessor(test.FILEPATH)
        self.assertTrue(pp.process())
Exemplo n.º 9
0
    def test_process(self):
        """
        Test process
        """
        show = TVShow(1, 3)
        show.name = test.SHOW_NAME
        show.location = test.SHOW_DIR
        show.saveToDB()

        sickbeard.showList = [show]
        episode = TVEpisode(show, test.SEASON, test.EPISODE)
        episode.name = "some episode name"
        episode.saveToDB()

        addNameToCache('show name', 3)
        sickbeard.PROCESS_METHOD = 'move'

        post_processor = PostProcessor(test.FILE_PATH)
        self.assertTrue(post_processor.process())
Exemplo n.º 10
0
    def test_process(self):
        """
        Test process
        """
        show = TVShow(1, 3)
        show.name = test.SHOW_NAME
        show.location = test.SHOW_DIR
        show.saveToDB()

        sickbeard.showList = [show]
        episode = TVEpisode(show, test.SEASON, test.EPISODE)
        episode.name = "some episode name"
        episode.saveToDB()

        addNameToCache('show name', 3)
        sickbeard.PROCESS_METHOD = 'move'

        post_processor = PostProcessor(test.FILE_PATH)
        self.assertTrue(post_processor.process())
Exemplo n.º 11
0
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join('Show Name', 'associated_files', 'random', 'recursive', 'subdir')

        file_names = [
            'Show Name [SickChill].avi',
            'Show Name [SickChill].srt',
            'Show Name [SickChill].nfo',
            'Show Name [SickChill].en.srt',
            'Non-Associated Show [SickChill].srt',
            'Non-Associated Show [SickChill].en.srt',
            'Show [SickChill] Non-Associated.en.srt',
            'Show [SickChill] Non-Associated.srt',
        ]
        self.file_list = [os.path.join('Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor('Show Name')
        self.maxDiff = None
        sickbeard.MOVE_ASSOCIATED_FILES = True
        sickbeard.ALLOWED_EXTENSIONS = ''
Exemplo n.º 12
0
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join(u'Show Name', u'associated_files',
                                      u'random', u'recursive', u'subdir')

        file_names = [
            u'Show Name [SickRage].avi',
            u'Show Name [SickRage].srt',
            u'Show Name [SickRage].nfo',
            u'Show Name [SickRage].en.srt',
            u'Non-Associated Show [SickRage].srt',
            u'Non-Associated Show [SickRage].en.srt',
            u'Show [SickRage] Non-Associated.en.srt',
            u'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [
            os.path.join(u'Show Name', f) for f in file_names
        ] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor(u'Show Name')
        self.maxDiff = None
Exemplo n.º 13
0
    def test_process(self):
        show = TVShow(1, 3)
        show.name = SHOWNAME
        show.location = SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, SEASON, EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        addNameToCache('show name', 3)
        self.pp = PostProcessor(FILEPATH, process_method='move')
        self.assertTrue(self.pp.process())
Exemplo n.º 14
0
    def test(self):

        self.showDir = test_lib.setUp_test_show_dir(show_name)
        self.filePath = test_lib.setUp_test_episode_file(
            None, curData["b"] + ".mkv")

        show = TVShow(tvdbdid)
        show.name = show_name
        show.quality = curData["q"]
        show.location = self.showDir
        if curData["anime"]:
            show.anime = 1
        show.saveToDB()
        sickbeard.showList.append(show)

        for epNumber in curData["e"]:
            episode = TVEpisode(show, curData["s"], epNumber)
            episode.status = c.WANTED
            if "ab" in curData:
                episode.absolute_number = curData["ab"]
            episode.saveToDB()

        pp = PostProcessor(self.filePath)
        self.assertTrue(pp.process())
Exemplo n.º 15
0
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join(u'Show Name', u'associated_files', u'random', u'recursive', u'subdir')

        file_names = [
            u'Show Name [SickRage].avi',
            u'Show Name [SickRage].srt',
            u'Show Name [SickRage].nfo',
            u'Show Name [SickRage].en.srt',
            u'Non-Associated Show [SickRage].srt',
            u'Non-Associated Show [SickRage].en.srt',
            u'Show [SickRage] Non-Associated.en.srt',
            u'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [os.path.join(u'Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor(u'Show Name')
        self.maxDiff = None
Exemplo n.º 16
0
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join('Show Name', 'associated_files', 'random', 'recursive', 'subdir')

        file_names = [
            'Show Name [SickRage].avi',
            'Show Name [SickRage].srt',
            'Show Name [SickRage].nfo',
            'Show Name [SickRage].en.srt',
            'Non-Associated Show [SickRage].srt',
            'Non-Associated Show [SickRage].en.srt',
            'Show [SickRage] Non-Associated.en.srt',
            'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [os.path.join('Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor('Show Name')
        self.maxDiff = None
        sickbeard.MOVE_ASSOCIATED_FILES = True
        sickbeard.ALLOWED_EXTENSIONS = u''
Exemplo n.º 17
0
class PPBasicTests(test.SiCKRAGETestDBCase):
    def setUp(self):
        super(PPBasicTests, self).setUp()

    def tearDown(self):
        super(PPBasicTests, self).tearDown()

    def test_process(self):
        show = TVShow(1, 3)
        show.name = test.SHOWNAME
        show.location = test.SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, test.SEASON, test.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        addNameToCache('show name', 3)
        self.pp = PostProcessor(test.FILEPATH, process_method='move')
        self.assertTrue(self.pp.process())
Exemplo n.º 18
0
class PPBasicTests(SiCKRAGETestDBCase):
    def setUp(self, **kwargs):
        super(PPBasicTests, self).setUp()

    def tearDown(self, **kwargs):
        super(PPBasicTests, self).tearDown()

    def test_process(self):
        show = TVShow(1, 3)
        show.name = SHOWNAME
        show.location = SHOWDIR
        show.saveToDB()

        sickbeard.showList = [show]
        ep = TVEpisode(show, SEASON, EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        addNameToCache('show name', 3)
        self.pp = PostProcessor(FILEPATH, process_method='move')
        self.assertTrue(self.pp.process())
Exemplo n.º 19
0
class PPPrivateTests(test_lib.SickbeardTestDBCase):
    def setUp(self):
        super(PPPrivateTests, self).setUp()

        sickbeard.showList = [TVShow(0000), TVShow(0001)]

        self.pp = PostProcessor(test_lib.FILEPATH)
        self.show_obj = TVShow(0002)

        self.db = test_lib.db.DBConnection()
        newValueDict = {
            "tvdbid": 1002,
            "name": test_lib.SHOWNAME,
            "description": "description",
            "airdate": 1234,
            "hasnfo": 1,
            "hastbn": 1,
            "status": 404,
            "location": test_lib.FILEPATH
        }
        controlValueDict = {
            "showid": 0002,
            "season": test_lib.SEASON,
            "episode": test_lib.EPISODE
        }

        # use a custom update/insert method to get the data into the DB
        self.db.upsert("tv_episodes", newValueDict, controlValueDict)

        self.ep_obj = TVEpisode(self.show_obj, test_lib.SEASON,
                                test_lib.EPISODE, test_lib.FILEPATH)

    def test__find_ep_destination_folder(self):
        self.show_obj.location = test_lib.FILEDIR
        self.ep_obj.show.seasonfolders = 1
        sickbeard.SEASON_FOLDERS_FORMAT = 'Season %02d'
        calculatedPath = self.pp._find_ep_destination_folder(self.ep_obj)
        ecpectedPath = os.path.join(test_lib.FILEDIR,
                                    "Season 0" + str(test_lib.SEASON))
        self.assertEqual(calculatedPath, ecpectedPath)
Exemplo n.º 20
0
class PPPrivateTests(test.SickbeardTestDBCase):


    def setUp(self):
        super(PPPrivateTests, self).setUp()

        sickbeard.showList = [TVShow(0000), TVShow(0001)]

        self.pp = PostProcessor(test.FILEPATH)
        self.show_obj = TVShow(0002)

        self.db = test.db.DBConnection()
        newValueDict = {"tvdbid": 1002,
                        "name": test.SHOWNAME,
                        "description": "description",
                        "airdate": 1234,
                        "hasnfo": 1,
                        "hastbn": 1,
                        "status": 404,
                        "location": test.FILEPATH}
        controlValueDict = {"showid": 0002,
                            "season": test.SEASON,
                            "episode": test.EPISODE}

        # use a custom update/insert method to get the data into the DB
        self.db.upsert("tv_episodes", newValueDict, controlValueDict)

        self.ep_obj = TVEpisode(self.show_obj, test.SEASON, test.EPISODE, test.FILEPATH)

    def tearDown(self):
        self.db.close()

    def test__find_ep_destination_folder(self):
        self.show_obj.location = test.FILEDIR
        self.ep_obj.show.seasonfolders = 1
        sickbeard.SEASON_FOLDERS_FORMAT = 'Season %02d'
        calculatedPath = self.pp._find_ep_destination_folder(self.ep_obj)
        ecpectedPath = os.path.join(test.FILEDIR, "Season 0" + str(test.SEASON))
        self.assertEqual(calculatedPath, ecpectedPath)
Exemplo n.º 21
0
 def setUp(self):
     super(PPInitTests, self).setUp()
     self.pp = PostProcessor(test.FILEPATH)
Exemplo n.º 22
0
class ListAssociatedFiles(unittest.TestCase):
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join(u'Show Name', u'associated_files',
                                      u'random', u'recursive', u'subdir')

        file_names = [
            u'Show Name [SickRage].avi',
            u'Show Name [SickRage].srt',
            u'Show Name [SickRage].nfo',
            u'Show Name [SickRage].en.srt',
            u'Non-Associated Show [SickRage].srt',
            u'Non-Associated Show [SickRage].en.srt',
            u'Show [SickRage] Non-Associated.en.srt',
            u'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [
            os.path.join(u'Show Name', f) for f in file_names
        ] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor(u'Show Name')
        self.maxDiff = None

    def setUp(self):
        make_dirs(self.test_tree)
        for test_file in self.file_list:
            open(test_file, 'a').close()

    def tearDown(self):
        shutil.rmtree(u'Show Name')

    def test_subfolders(self):
        associated_files = self.post_processor.list_associated_files(
            self.file_list[0], subfolders=True)

        associated_files = sorted(
            file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:]
                          if 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(
            self.file_list[0], subfolders=False)

        associated_files = sorted(
            file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:]
                          if 'associated_files' not in file_name
                          and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only(self):
        associated_files = self.post_processor.list_associated_files(
            self.file_list[0], subtitles_only=True, subfolders=True)

        associated_files = sorted(
            file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list
                          if file_name.endswith('.srt')
                          and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(
            self.file_list[0], subtitles_only=True, subfolders=False)
        associated_files = sorted(
            file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(
            file_name for file_name in self.file_list
            if file_name.endswith('.srt') and 'associated_files' not in
            file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)
Exemplo n.º 23
0
class ListAssociatedFiles(unittest.TestCase):
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join('Show Name', 'associated_files', 'random', 'recursive', 'subdir')

        file_names = [
            'Show Name [SickRage].avi',
            'Show Name [SickRage].srt',
            'Show Name [SickRage].nfo',
            'Show Name [SickRage].en.srt',
            'Non-Associated Show [SickRage].srt',
            'Non-Associated Show [SickRage].en.srt',
            'Show [SickRage] Non-Associated.en.srt',
            'Show [SickRage] Non-Associated.srt',
        ]
        self.file_list = [os.path.join('Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor('Show Name')
        self.maxDiff = None
        sickbeard.MOVE_ASSOCIATED_FILES = True
        sickbeard.ALLOWED_EXTENSIONS = u''

    def setUp(self):
        make_dirs(self.test_tree)
        for test_file in self.file_list:
            open(test_file, 'a').close()

    def tearDown(self):
        shutil.rmtree('Show Name')

    def test_subfolders(self):
        # Test edge cases first:
        self.assertEqual([], # empty file_path
            self.post_processor.list_associated_files('', subfolders=True))
        self.assertEqual([], # no file name
                         self.post_processor.list_associated_files('\\Show Name\\.nomedia', subfolders=True))

        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

        # Test no associated files:
        associated_files = self.post_processor.list_associated_files('Fools Quest.avi', subfolders=True)

    def test_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=False)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=False)
        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)
Exemplo n.º 24
0
 def setUp(self):
     self.pp = PostProcessor(test.FILEPATH)
Exemplo n.º 25
0
class ListAssociatedFiles(unittest.TestCase):
    def __init__(self, test_case):
        super(ListAssociatedFiles, self).__init__(test_case)
        self.test_tree = os.path.join('Show Name', 'associated_files', 'random', 'recursive', 'subdir')

        file_names = [
            'Show Name [SickChill].avi',
            'Show Name [SickChill].srt',
            'Show Name [SickChill].nfo',
            'Show Name [SickChill].en.srt',
            'Non-Associated Show [SickChill].srt',
            'Non-Associated Show [SickChill].en.srt',
            'Show [SickChill] Non-Associated.en.srt',
            'Show [SickChill] Non-Associated.srt',
        ]
        self.file_list = [os.path.join('Show Name', f) for f in file_names] + [os.path.join(self.test_tree, f) for f in file_names]
        self.post_processor = PostProcessor('Show Name')
        self.maxDiff = None
        sickbeard.MOVE_ASSOCIATED_FILES = True
        sickbeard.ALLOWED_EXTENSIONS = ''

    def setUp(self):
        make_dirs(self.test_tree)
        for test_file in self.file_list:
            open(test_file, 'a').close()

    def tearDown(self):
        shutil.rmtree('Show Name')

    def test_subfolders(self):
        # Test edge cases first:
        self.assertEqual([], # empty file_path
            self.post_processor.list_associated_files('', subfolders=True))
        self.assertEqual([], # no file name
                         self.post_processor.list_associated_files('\\Show Name\\.nomedia', subfolders=True))

        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

        # Test no associated files:
        associated_files = self.post_processor.list_associated_files('Fools Quest.avi', subfolders=True)

    def test_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subfolders=False)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list[1:] if 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=True)

        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)

    def test_subtitles_only_no_subfolders(self):
        associated_files = self.post_processor.list_associated_files(self.file_list[0], subtitles_only=True, subfolders=False)
        associated_files = sorted(file_name.lstrip('./') for file_name in associated_files)
        out_list = sorted(file_name for file_name in self.file_list if file_name.endswith('.srt') and 'associated_files' not in file_name and 'Non-Associated' not in file_name)

        self.assertEqual(out_list, associated_files)
Exemplo n.º 26
0
 def setUp(self):
     """
     Set up tests
     """
     self.post_processor = PostProcessor(test.FILE_PATH)
Exemplo n.º 27
0
 def setUp(self, **kwargs):
     super(PPInitTests, self).setUp()
     self.pp = PostProcessor(FILEPATH)