예제 #1
0
    def test_invalid_language(self):
        """Search function should raise TVDBValueError when trying to search
        with an invalid language
        """
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBValueError, api.search, "dexter", "lu")
예제 #2
0
    def test_iterate_search(self):
        """It should be possible to iterate over a search result"""
        api = TVDB("B43FF87DE395DF56")
        search = api.search("house", "en")

        for s in search:
            self.assertEqual(type(s), pytvdbapi.api.Show)
예제 #3
0
    def test_non_date(self):
        """Function should raise an exception if the air_date parameter is of the wrong type"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBValueError, api.get_episode_by_air_date, 79349, 'en', 'foo')
        self.assertRaises(error.TVDBValueError, api.get_episode_by_air_date, 79349, 'en', '2001-12-21')
        self.assertRaises(error.TVDBValueError, api.get_episode_by_air_date, 79349, 'en', 2)
예제 #4
0
    def test_invalid_method(self):
        """Function should raise TVDBValueError if an invalid method is passed"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", -1)
        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "foo")
        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "")
예제 #5
0
    def test_default_order(self):
        """It should be possible to get an episode using the default sort order"""
        api = TVDB("B43FF87DE395DF56")

        ep = api.get_episode(0, "en", "default", True, seriesid=79349, seasonnumber=2, episodenumber=5)

        self.assertEqual(ep.absolute_number, 17)
예제 #6
0
    def test_invalid_id(self):
        """If the show can not be found, a TVDBValueError should be raised"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBIdError, api.get, 99999999999999, "en")
        self.assertRaises(error.TVDBIdError, api.get, "foo", "en")
        self.assertRaises(error.TVDBIdError, api.get, "", "en")
예제 #7
0
    def test_get(self):
        """Provided the show id, you should be able to get the show object"""
        api = TVDB("B43FF87DE395DF56")
        show = api.get_series(79349, "en")

        self.assertEqual(show.SeriesName, "Dexter")
        self.assertEqual(show.id, 79349)
예제 #8
0
    def test_missing_arguments(self):
        """Function should raise TVDBValueError if arguments for the method is missing"""
        api = TVDB("B43FF87DE395DF56")

        # self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "id")
        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "default")
        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "dvd")
        self.assertRaises(error.TVDBValueError, api.get_episode, 308834, "en", "absolute")
예제 #9
0
    def test_episode_id_kwarg(self):
        """It should be possible to load the episode passing the episode id as a kwarg"""
        api = TVDB("B43FF87DE395DF56")

        ep = api.get_episode(0, "en", "id", True, episodeid=308834)

        self.assertEqual(ep.id, 308834)
        self.assertEqual(ep.EpisodeName, 'Crocodile')
예제 #10
0
    def test_missing_id(self):
        """It should be possible to call get_episode without passing id as positional argument"""
        api = TVDB("B43FF87DE395DF56")

        ep = api.get_episode("en", "id", True, episodeid=308834)

        self.assertEqual(ep.id, 308834)
        self.assertEqual(ep.EpisodeName, 'Crocodile')
예제 #11
0
    def test_valid_show(self):
        """Given correct values, the function should return a valid Episode instance"""
        api = TVDB("B43FF87DE395DF56")

        # Second episode of dexter
        ep = api.get_episode_by_air_date(79349, 'en', datetime.date(2006, 10, 8))

        self.assertEqual(ep.id, 308834)
        self.assertEqual(ep.EpisodeName, 'Crocodile')
예제 #12
0
    def test_imdb_id(self):
        """It should be possible to use the imdb id to get the series"""
        api = TVDB("B43FF87DE395DF56")

        show = api.get_series(773262, 'en', 'imdb')
        self.assertEqual(show.seriesid, 79349)  # Dexter

        show = api.get_series('tt0773262', 'en', 'imdb')
        self.assertEqual(show.seriesid, 79349)  # Dexter
예제 #13
0
    def test_zap2it_id(self):
        """It should be possible to load the show using the zap2it id"""
        api = TVDB("B43FF87DE395DF56")

        show = api.get_series('EP00859795', 'en', 'zap2it')
        self.assertEqual(show.seriesid, 79349)  # Dexter

        show = api.get_series(859795, 'en', 'zap2it')
        self.assertEqual(show.seriesid, 79349)  # Dexter
예제 #14
0
    def test_invalid_language(self):
        """
        Function should raise TVDBValueError if an invalid language is
        passed
        """

        api = TVDB("B43FF87DE395DF56")
        self.assertRaises(error.TVDBValueError, api.get_series, 79349, "foo")
        self.assertRaises(error.TVDBValueError, api.get_series, 79349, "")
예제 #15
0
    def test_get_series(self):
        """
        It should be possible to use the get_series alias to get a show
        given the right show id.
        """
        api = TVDB("B43FF87DE395DF56")
        show = api.get_series(79349, "en")

        self.assertEqual(show.SeriesName, "Dexter")
        self.assertEqual(show.id, 79349)
예제 #16
0
    def test_get_episode(self):
        """
        Provided the episode id, you should be able to
        get episode instance.
        """
        api = TVDB("B43FF87DE395DF56")
        ep = api.get_episode(308834, "en")

        self.assertEqual(ep.id, 308834)
        self.assertEqual(ep.EpisodeName, 'Crocodile')
예제 #17
0
    def test_iterable_actors(self):
        """
        It should be possible to iterate over the actor objects
        """
        api = TVDB("B43FF87DE395DF56", actors=True)
        show = api.get(79349, "en")  # Load the series Dexter
        show.update()

        for actor in show.actor_objects:
            self.assertEqual(type(actor), Actor)
예제 #18
0
    def test_get_actors(self):
        """
        The Show instance should have an actor_objects attribute when the
        actor data is loaded.
        """
        api = TVDB("B43FF87DE395DF56", actors=True)
        show = api.get(79349, "en")  # Load the series Dexter
        show.update()

        self.assertEqual(hasattr(show, "actor_objects"), True)
    def test_no_actors(self):
        """
        The Show instance should have an empty actor_objects when the
        actor data has not been loaded.
        """
        api = TVDB("B43FF87DE395DF56", actors=False)
        show = api.get_series(79349, "en")  # Load the series Dexter
        show.update()

        self.assertEqual(len(show.actor_objects), 0)
예제 #20
0
    def test_invalid_id(self):
        """Function should raise bad data exception if an invalid id is passed"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.BadData, api.get_episode, "en", "id", True, episodeid=0, seriesid=81797)
        self.assertRaises(error.TVDBNotFoundError,
                          api.get_episode, "en", "id", True, episodeid=-1, seriesid=81797)
        self.assertRaises(error.TVDBNotFoundError,
                          api.get_episode, "en", "id", True, episodeid="foo", seriesid=81797)
        self.assertRaises(error.BadData,
                          api.get_episode, "en", "id", True, episodeid=99999999999, seriesid=81797)
예제 #21
0
    def test_invalid_search_index(self):
        """Search should raise TVDBIndexError when trying to access an
        invalid index
        """
        api = TVDB("B43FF87DE395DF56")
        search = api.search("dexter", "en")

        self.assertRaises(error.TVDBIndexError, search.__getitem__, 10)
        self.assertRaises(error.TVDBIndexError, search.__getitem__, 50)
        self.assertRaises(error.TVDBIndexError, search.__getitem__, 100)
        self.assertRaises(error.TVDBValueError, search.__getitem__, "foo")
예제 #22
0
    def test_invalid_actor_attribute(self):
        """
        Actor instance should raise an exception when accessing an invalid
        attribute.
        """
        api = TVDB("B43FF87DE395DF56", actors=True)
        show = api.get(79349, "en")  # Load the series Dexter
        show.update()

        actor = show.actor_objects[0]
        self.assertRaises(error.TVDBAttributeError, actor.__getattr__, 'foo')
예제 #23
0
    def test_invalid_id(self):
        """Function should raise an exception if an invalid id is used"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBNotFoundError,
                          api.get_episode_by_air_date, 'foo', 'en', datetime.date(2006, 10, 8))

        self.assertRaises(error.TVDBNotFoundError,
                          api.get_episode_by_air_date, -1, 'en', datetime.date(2006, 10, 8))

        self.assertRaises(error.TVDBNotFoundError,
                          api.get_episode_by_air_date, 999999, 'en', datetime.date(2006, 10, 8))
예제 #24
0
    def test_actor_representation(self):
        """
        The representation of the actor should be properly formatted.
        """
        api = TVDB("B43FF87DE395DF56", actors=True)
        show = api.get(79349, "en")  # Load the series Dexter
        show.update()

        regexp = re.compile("^<Actor - .*?>$")

        for actor in show.actor_objects:
            self.assertNotEqual(regexp.match(actor.__repr__()), None)
예제 #25
0
    def test_attribute_case(self):
        """
        When ignore_case is False, all attributes should be case sensitive
        """
        api = TVDB("B43FF87DE395DF56", ignore_case=False)
        search = api.search("friends", 'en')

        # Load and update the show
        show = search[0]
        show.update()

        self.assertRaises(error.TVDBAttributeError, show.__getattr__, "ImDB_id")
예제 #26
0
    def test_invalid_language(self):
        """Function should raise an exception if an invalid language is passed"""
        api = TVDB("B43FF87DE395DF56")

        self.assertRaises(error.TVDBValueError,
                          api.get_episode_by_air_date, 79349, 'foo', datetime.date(2006, 10, 8))

        self.assertRaises(error.TVDBValueError,
                          api.get_episode_by_air_date, 79349, 2, datetime.date(2006, 10, 8))

        self.assertRaises(error.TVDBValueError,
                          api.get_episode_by_air_date, 79349, 'english', datetime.date(2006, 10, 8))
    def test_insensitive_attributes(self):
        """If selected, it should be possible to access the attributes in a case insensitive manner"""

        api = TVDB("B43FF87DE395DF56", actors=True, ignore_case=True)
        show = api.get_series(79349, "en")  # Load the series Dexter
        show.update()

        actor = show.actor_objects[0]
        for a in dir(actor):
            self.assertTrue(hasattr(actor, a))
            self.assertTrue(hasattr(actor, a.lower()))
            self.assertTrue(hasattr(actor, a.upper()))
예제 #28
0
    def test_unicode_search(self):
        """
        It should be possible to search for shows containing non ascii chars
        """

        api = TVDB("B43FF87DE395DF56")

        search = api.search("Alarm für cobra 11", "de")
        show = search[0]
        self.assertEqual(show[1][2].EpisodeName, "Rote Rosen, schwarzer Tod")

        search = api.search('3年B組金八先生', "zh")
        show = search[0]
        self.assertEqual(show[1][1].EpisodeName, "3年B組金八先生")
예제 #29
0
    def test_search(self):
        """It should be possible to search for shows"""
        api = TVDB("B43FF87DE395DF56")
        search = api.search("dexter", "en")

        self.assertEqual(len(search), 1)

        search = api.search("scrubs", "en")
        self.assertEqual(len(search), 2)

        search = api.search("dexter", "en")

        self.assertEqual(len(search), 1)
        self.assertEqual(search.search, "dexter")
예제 #30
0
    def test_ignore_case(self):
        """
        It should be possible to pass the ignore_case keyword to the api
        and access all show/season/episode attributes in a case insensitive
        way.
        """
        api = TVDB("B43FF87DE395DF56", ignore_case=True)
        search = api.search("friends", 'en')

        # Load and update the show
        show = search[0]
        show.update()

        self.assertEqual(show.IMDB_ID, show.imdb_id)
        self.assertEqual(show.ImDB_id, show.imDb_Id)