예제 #1
0
    def test_mustgivestr(self):
        with self.assertRaises(TypeError):
            imdb.getseasons([])

        with self.assertRaises(TypeError):
            imdb.getnumseasons([])

        with self.assertRaises(TypeError):
            imdb.getepisodes([])

        with self.assertRaises(TypeError):
            imdb.getnumepisodes([])

        with self.assertRaises(TypeError):
            imdb.getshow([])
예제 #2
0
 def getshow(self, showname, update=False):
     """ Retrieve a show from the cache. If it does not already exist in
     the cache, it will be retrieved from the internet. At this point in time
     only imdb is searched.
     """
     # cache hit, not forced update
     if not update and self._shows is not None and showname in self._shows:
         if not isinstance(self._shows[showname], Show):
             self._shows[showname] = self._dicttoshow(showname, self._shows[showname])
         return self._shows[showname]
     # check if we have already read something from cache
     if self._shows is None:
         self._shows = self._readcache()
         # check if cache was empty
         if self._shows is None:
             self._shows = {}
     # check if we should update show cache
     if update or showname not in self._shows:
         showtmp = imdb.getshow(showname)
         if showname in self._shows:
             showtmp = self._saveepisodeproperties(showname, self._shows[showname], showtmp)
         self._shows[showname] = showtmp
         self._savecache(self._shows)
     # make sure that show is instance of Show
     if not isinstance(self._shows[showname], Show):
         self._shows[showname] = self._dicttoshow(showname, self._shows[showname])
     return self._shows[showname]
예제 #3
0
    def test_getshow(self):
        show = imdb.getshow(self.showname)
        self.assertIsInstance(show, Show)

        # check that seasons have the following number of episodes
        # this test might fail in the future, if imdb modifies its data
        for i in range(9):
            season = show.getseason(i + 1)
            self.assertIsInstance(season, Season)
            self.assertGreaterEqual(len(season.episodes), self.numepisodes[i])
            for j in range(self.numepisodes[i]):
                self.assertTrue(season.hasepisode(j + 1))
                self.assertIsInstance(season.getepisode(j + 1), Episode)