コード例 #1
0
ファイル: tv_tests.py プロジェクト: Thraxis/pymedusa
 def test_set_name(self):
     """
     test set name
     """
     show = TVShow(1, 1, "en")
     show.name = "newName"
     show.save_to_db()
     show._load_from_db()
     self.assertEqual(show.name, "newName")
コード例 #2
0
ファイル: pp_tests.py プロジェクト: v0re/SickGear
    def _create_ep(tvid):
        show_obj = TVShow(tvid, 3)
        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.location = '/mnt/hdd/folder/the show/season 01/the show - s01e01 - name.mkv'
        ep_obj.save_to_db()
        return ep_obj
コード例 #3
0
 def test_getEpisode():
     show_obj = TVShow(1, 1, 'en')
     show_obj.name = 'show name'
     show_obj.tvrname = 'show name'
     show_obj.network = 'cbs'
     show_obj.genre = 'crime'
     show_obj.runtime = 40
     show_obj.status = '5'
     show_obj.airs = 'monday'
     show_obj.startyear = 1987
     show_obj.save_to_db()
     sickbeard.showList = [show_obj]
コード例 #4
0
ファイル: tv_tests.py プロジェクト: Thraxis/pymedusa
 def test_get_episode():
     """
     Test get episodes
     """
     show = TVShow(1, 1, "en")
     show.name = "show name"
     show.network = "cbs"
     show.genre = "crime"
     show.runtime = 40
     show.status = "Ended"
     show.default_ep_status = "5"
     show.airs = "monday"
     show.startyear = 1987
     show.save_to_db()
     sickbeard.showList = [show]
コード例 #5
0
ファイル: pp_tests.py プロジェクト: v0re/SickGear
    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())
コード例 #6
0
    def test_change_indexerid(self):
        show_obj = TVShow(1, 1, 'en')
        show_obj.name = 'show name'
        show_obj.tvrname = 'show name'
        show_obj.network = 'cbs'
        show_obj.genre = 'crime'
        show_obj.runtime = 40
        show_obj.status = '5'
        show_obj.airs = 'monday'
        show_obj.startyear = 1987

        show_obj.save_to_db()
        show_obj.load_from_db()

        show_obj.prodid = 2
        show_obj.save_to_db()
        show_obj.load_from_db()

        self.assertEqual(show_obj.prodid, 2)
コード例 #7
0
ファイル: pp_tests.py プロジェクト: Thraxis/pymedusa
    def test_process(self):
        """
        Test process
        """
        show = TVShow(1, 3)
        show.name = test.SHOW_NAME
        show.location = test.SHOW_DIR
        show.save_to_db()

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

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

        post_processor = PostProcessor(test.FILE_PATH)
        self.assertTrue(post_processor.process())
コード例 #8
0
ファイル: snatch_tests.py プロジェクト: swipswaps/SickGear
    def test(self):
        global searchItems
        searchItems = curData['i']
        show_obj = TVShow(1, tvdbdid)
        show_obj.name = show_name
        show_obj.quality = curData['q']
        show_obj.save_to_db()
        sickbeard.showList.append(show_obj)
        sickbeard.showDict[show_obj.sid_int] = show_obj
        episode = None

        for epNumber in curData['e']:
            episode = TVEpisode(show_obj, curData['s'], epNumber)
            episode.status = c.WANTED
            episode.save_to_db()

        bestResult = search.search_providers(show_obj, episode.season, episode.episode, forceSearch)
        if not bestResult:
            self.assertEqual(curData['b'], bestResult)
        self.assertEqual(curData['b'], bestResult.name) #first is expected, second is choosen one
コード例 #9
0
ファイル: tv_tests.py プロジェクト: Thraxis/pymedusa
    def test_change_indexerid(self):
        """
        test change indexer id
        """
        show = TVShow(1, 1, "en")
        show.name = "show name"
        show.network = "cbs"
        show.genre = "crime"
        show.runtime = 40
        show.status = "Ended"
        show.default_ep_status = "5"
        show.airs = "monday"
        show.startyear = 1987

        show.save_to_db()
        show._load_from_db()

        show.indexerid = 2
        show.save_to_db()
        show._load_from_db()

        self.assertEqual(show.indexerid, 2)
コード例 #10
0
ファイル: snatch_tests.py プロジェクト: Thraxis/pymedusa
    def do_test():
        """
        Test to perform
        """
        global search_items  # pylint: disable=global-statement
        search_items = cur_data["i"]
        show = TVShow(1, tvdb_id)
        show.name = show_name
        show.quality = cur_data["q"]
        show.save_to_db()
        sickbeard.showList.append(show)
        episode = None

        for epNumber in cur_data["e"]:
            episode = TVEpisode(show, cur_data["s"], epNumber)
            episode.status = common.WANTED
            episode.save_to_db()

        best_result = search.searchProviders(show, episode.episode, force_search)
        if not best_result:
            assert cur_data["b"] == best_result
        # pylint: disable=no-member
        assert cur_data["b"] == best_result.name  # first is expected, second is chosen one
コード例 #11
0
ファイル: notifier_tests.py プロジェクト: Thraxis/pymedusa
    def setUpClass(cls):
        num_legacy_shows = 3
        num_shows = 3
        num_episodes_per_show = 5
        cls.mydb = db.DBConnection()
        cls.legacy_shows = []
        cls.shows = []

        # Per-show-notifications were originally added for email notifications only.  To add
        # this feature to other notifiers, it was necessary to alter the way text is stored in
        # one of the DB columns.  Therefore, to test properly, we must create some shows that
        # store emails in the old method (legacy method) and then other shows that will use
        # the new method.
        for show_counter in range(100, 100 + num_legacy_shows):
            show = TVShow(1, show_counter)
            show.name = "Show " + str(show_counter)
            show.episodes = []
            for episode_counter in range(0, num_episodes_per_show):
                episode = TVEpisode(show, test.SEASON, episode_counter)
                episode.name = "Episode " + str(episode_counter + 1)
                episode.quality = "SDTV"
                show.episodes.append(episode)
            show.save_to_db()
            cls.legacy_shows.append(show)

        for show_counter in range(200, 200 + num_shows):
            show = TVShow(1, show_counter)
            show.name = "Show " + str(show_counter)
            show.episodes = []
            for episode_counter in range(0, num_episodes_per_show):
                episode = TVEpisode(show, test.SEASON, episode_counter)
                episode.name = "Episode " + str(episode_counter + 1)
                episode.quality = "SDTV"
                show.episodes.append(episode)
            show.save_to_db()
            cls.shows.append(show)
コード例 #12
0
ファイル: search_tests.py プロジェクト: Thraxis/pymedusa
    def do_test(self):
        """
        Test to perform
        """
        show = TVShow(1, int(cur_data["tvdbid"]))
        show.name = cur_name
        show.quality = common.ANY | common.Quality.UNKNOWN | common.Quality.RAWHDTV
        show.save_to_db()
        sickbeard.showList.append(show)

        for ep_number in cur_data["e"]:
            episode = TVEpisode(show, cur_data["s"], ep_number)
            episode.status = common.WANTED

            # We aren't updating scene numbers, so fake it here
            episode.scene_season = cur_data["s"]
            episode.scene_episode = ep_number

            episode.save_to_db()

            cur_provider.show = show
            season_strings = cur_provider._get_season_search_strings(episode)  # pylint: disable=protected-access
            episode_strings = cur_provider._get_episode_search_strings(episode)  # pylint: disable=protected-access

            fail = False
            cur_string = ''
            for cur_string in season_strings, episode_strings:
                if not all([isinstance(cur_string, list), isinstance(cur_string[0], dict)]):
                    print(" %s is using a wrong string format!" % cur_provider.name)
                    print(cur_string)
                    fail = True
                    continue

            if fail:
                continue

            try:
                assert season_strings == cur_data["s_strings"]
                assert episode_strings == cur_data["e_strings"]
            except AssertionError:
                print (" %s is using a wrong string format!" % cur_provider.name)
                print (cur_string)
                continue

            search_strings = episode_strings[0]
            # search_strings.update(season_strings[0])
            # search_strings.update({"RSS":['']})

            # print(search_strings)

            if not cur_provider.public:
                continue

            items = cur_provider.search(search_strings)  # pylint: disable=protected-access
            if not items:
                print("No results from cur_provider?")
                continue

            title, url = cur_provider._get_title_and_url(items[0])  # pylint: disable=protected-access
            for word in show.name.split(" "):
                if not word.lower() in title.lower():
                    print("Show cur_name not in title: %s. URL: %s" % (title, url))
                    continue

            if not url:
                print("url is empty")
                continue

            quality = cur_provider.get_quality(items[0])
            size = cur_provider._get_size(items[0])  # pylint: disable=protected-access

            if not show.quality & quality:
                print("Quality not in common.ANY, %r %s" % (quality, size))
                continue
コード例 #13
0
 def test_set_name(self):
     show_obj = TVShow(1, 1, 'en')
     show_obj.name = 'newName'
     show_obj.save_to_db()
     show_obj.load_from_db()
     self.assertEqual(show_obj.name, 'newName')
コード例 #14
0
ファイル: show_tests.py プロジェクト: swipswaps/SickGear
    def test_getWanted(self):
        for ep_base, w in enumerate(wanted_tests):
            show_obj = TVShow(w['show']['indexer'], w['show']['indexerid'],
                              'en')
            show_obj.name = 'show name'
            show_obj.tvrname = 'show name'
            show_obj.quality = w['show']['quality']
            show_obj.network = 'cbs'
            show_obj.genre = 'crime'
            show_obj.runtime = 40
            show_obj.status = '5'
            show_obj.airs = 'monday'
            show_obj.startyear = 1987
            show_obj.save_to_db()
            sickbeard.showList = [show_obj]
            sickbeard.showDict[show_obj.sid_int] = show_obj
            cl = []
            ep_id = ep_base * 10000
            for ep in w['episodes']:
                ep_id += 1
                if ep['season'] not in show_obj.sxe_ep_obj:
                    show_obj.sxe_ep_obj[ep['season']] = {}
                show_obj.sxe_ep_obj[ep['season']][ep['episode']] = TVEpisode(
                    show_obj, ep['season'], ep['episode'])
                episode = show_obj.sxe_ep_obj[ep['season']][ep['episode']]
                episode.status = Quality.compositeStatus(
                    ep['status'], ep['quality'])
                episode.airdate = ep['airdate']
                episode.name = 'nothing'
                episode.epid = ep_id
                episode.show_obj = show_obj
                episode.tvid = show_obj.tvid
                cl.append(episode.get_sql())

            cur_db = db.DBConnection()
            if cl:
                cur_db.mass_action(cl)

            qi = QueueItemAdd(w['show']['indexer'], w['show']['indexerid'], '',
                              None, Quality.NONE, None, None, None, False,
                              False, False, None, None, w['start_wanted'],
                              w['end_wanted'], None, None)
            qi.show_obj = show_obj
            # start tests
            tr = qi._get_wanted(cur_db, w['start_wanted'], False)
            self.assertEqual(
                tr,
                w['result']['start'].get('count'),
                msg='%s: start: got: %s, expected: %s' %
                (w['name'], tr, w['result']['start'].get('count')))
            results = cur_db.select(
                'SELECT status, season, episode FROM tv_episodes WHERE indexer = ? AND showid = ?'
                ' ORDER BY season, episode', [show_obj.tvid, show_obj.prodid])
            for r in results:
                expected = w['result']['start'].get('episodes').get(
                    r['season'], {}).get(r['episode'], None)
                self.assertEqual(
                    r['status'],
                    expected,
                    msg='%s: start %sx%s: got: %s, expected: %s' %
                    (w['name'], r['season'], r['episode'],
                     statusStrings[r['status']], statusStrings[expected]))

            # end tests
            tr = qi._get_wanted(cur_db, w['end_wanted'], True)
            self.assertEqual(tr,
                             w['result']['end'].get('count'),
                             msg='%s: end: got: %s, expected: %s' %
                             (w['name'], tr, w['result']['end'].get('count')))
            results = cur_db.select(
                'SELECT status, season, episode FROM tv_episodes WHERE indexer = ? AND showid = ?'
                ' ORDER BY season, episode', [show_obj.tvid, show_obj.prodid])
            for r in results:
                expected = w['result']['end'].get('episodes').get(
                    r['season'], {}).get(r['episode'], None)
                self.assertEqual(
                    r['status'],
                    expected,
                    msg='%s: end %sx%s: got: %s, expected: %s' %
                    (w['name'], r['season'], r['episode'],
                     statusStrings[r['status']], statusStrings[expected]))