Ejemplo n.º 1
0
 def test_getEpisode(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
     sickbeard.showList = [show_obj]
     sickbeard.showDict = {show_obj.sid_int: show_obj}
     show_obj.sxe_ep_obj[1] = {}
     show_obj.sxe_ep_obj[1][1] = TVEpisode(show_obj, 1, 1, '16)')
     show_obj.sxe_ep_obj[1][1].dirty = False
     show_obj.sxe_ep_obj[1][1].name = None
     self.assertEqual(show_obj.sxe_ep_obj[1][1].dirty, False)
     self.assertEqual(
         show_obj.sxe_ep_obj[1][1]._format_pattern(
             '%SN - %Sx%0E - %EN - %QN'),
         'show name - 1x01 - tba - Unknown')
     show_obj.sxe_ep_obj[1][1].dirty = False
     show_obj.sxe_ep_obj[1][1].name = 'ep name'
     self.assertEqual(show_obj.sxe_ep_obj[1][1].dirty, True)
     self.assertEqual(
         show_obj.sxe_ep_obj[1][1]._format_pattern(
             '%SN - %Sx%0E - %EN - %QN'),
         'show name - 1x01 - ep name - Unknown')
Ejemplo n.º 2
0
 def test_getEpisode(self):
     show = TVShow(1, 1, 'en')
     show.name = 'show name'
     show.tvrname = 'show name'
     show.network = 'cbs'
     show.genre = 'crime'
     show.runtime = 40
     show.status = '5'
     show.airs = 'monday'
     show.startyear = 1987
     sickbeard.showList = [show]
     show.episodes[1] = {}
     show.episodes[1][1] = TVEpisode(show, 1, 1, '16)')
     show.episodes[1][1].dirty = False
     show.episodes[1][1].name = None
     self.assertEqual(show.episodes[1][1].dirty, False)
     self.assertEqual(
         show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'),
         'show name - 1x01 -  - Unknown')
     show.episodes[1][1].dirty = False
     show.episodes[1][1].name = 'ep name'
     self.assertEqual(show.episodes[1][1].dirty, True)
     self.assertEqual(
         show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'),
         'show name - 1x01 - ep name - Unknown')
Ejemplo n.º 3
0
 def test_getEpisode(self):
     show = TVShow(1, 1, "en")
     show.name = "show name"
     show.tvrname = "show name"
     show.network = "cbs"
     show.genre = "crime"
     show.runtime = 40
     show.status = "5"
     show.airs = "monday"
     show.startyear = 1987
     show.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 4
0
 def test_getEpisode(self):
     show = TVShow(1, 1, 'en')
     show.name = 'show name'
     show.tvrname = 'show name'
     show.network = 'cbs'
     show.genre = 'crime'
     show.runtime = 40
     show.status = '5'
     show.airs = 'monday'
     show.startyear = 1987
     show.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 5
0
 def test_getEpisode(self):
     show = TVShow(1, 1, "en")
     show.name = "show name"
     show.tvrname = "show name"
     show.network = "cbs"
     show.genre = "crime"
     show.runtime = 40
     show.status = "5"
     show.airs = "monday"
     show.startyear = 1987
     show.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 6
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]
Ejemplo n.º 7
0
 def test_getEpisode(self):
     show = TVShow(1, 1, 'en')
     show.name = 'show name'
     show.tvrname = 'show name'
     show.network = 'cbs'
     show.genre = 'crime'
     show.runtime = 40
     show.status = '5'
     show.airs = 'monday'
     show.startyear = 1987
     show.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 8
0
 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.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 9
0
 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.saveToDB()
     sickbeard.showList = [show]
Ejemplo n.º 10
0
    def test_change_indexerid(self):
        show = TVShow(1, 1, 'en')
        show.name = 'show name'
        show.tvrname = 'show name'
        show.network = 'cbs'
        show.genre = 'crime'
        show.runtime = 40
        show.status = '5'
        show.airs = 'monday'
        show.startyear = 1987

        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 11
0
    def test_change_indexerid(self):
        show = TVShow(1, 1, 'en')
        show.name = 'show name'
        show.tvrname = 'show name'
        show.network = 'cbs'
        show.genre = 'crime'
        show.runtime = 40
        show.status = '5'
        show.airs = 'monday'
        show.startyear = 1987

        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 12
0
    def test_change_indexerid(self):
        show = TVShow(1, 1, "en")
        show.name = "show name"
        show.tvrname = "show name"
        show.network = "cbs"
        show.genre = "crime"
        show.runtime = 40
        show.status = "5"
        show.airs = "monday"
        show.startyear = 1987

        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 13
0
    def test_change_indexerid(self):
        show = TVShow(1, 1, "en")
        show.name = "show name"
        show.tvrname = "show name"
        show.network = "cbs"
        show.genre = "crime"
        show.runtime = 40
        show.status = "5"
        show.airs = "monday"
        show.startyear = 1987

        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB(skipNFO=True)

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
 def test_getEpisode(self):
     show = TVShow(1, 1, 'en')
     show.name = 'show name'
     show.tvrname = 'show name'
     show.network = 'cbs'
     show.genre = 'crime'
     show.runtime = 40
     show.status = '5'
     show.airs = 'monday'
     show.startyear = 1987
     sickbeard.showList = [show]
     show.episodes[1] = {}
     show.episodes[1][1] = TVEpisode(show, 1, 1, '16)')
     show.episodes[1][1].dirty = False
     show.episodes[1][1].name = None
     self.assertEqual(show.episodes[1][1].dirty, False)
     self.assertEqual(show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'), 'show name - 1x01 -  - Unknown')
     show.episodes[1][1].dirty = False
     show.episodes[1][1].name = 'ep name'
     self.assertEqual(show.episodes[1][1].dirty, True)
     self.assertEqual(show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'), 'show name - 1x01 - ep name - Unknown')
Ejemplo n.º 16
0
    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.saveToDB()
        show.loadFromDB()

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB()

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 17
0
    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.saveToDB()
        show.loadFromDB()

        show.indexerid = 2
        show.saveToDB()
        show.loadFromDB()

        self.assertEqual(show.indexerid, 2)
Ejemplo n.º 18
0
    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]))