Beispiel #1
0
class AnonymousTvDBTestCase(BaseTestCase):
    """TvDB client without API key test case."""

    def setUp(self):
        super(AnonymousTvDBTestCase, self).setUp()
        self.tvdb = TvDB()

    def test_response_error(self):
        self.response(status_code=404)

        with self.assertRaises(APIResponseError):
            self.tvdb.search("something")

    def test_response_unexpected_content_type(self):
        self.response(status_code=200, content_type="text/plain")

        with self.assertRaises(APIResponseError):
            self.tvdb.search("something")

    def test_search_no_results(self):
        self.response(filename="empty.xml")
        results = self.tvdb.search("nothing")

        self.assertEqual(results, [])
        self.requests.get.assert_called_once_with(
            "http://thetvdb.com/api/GetSeries.php", params={"seriesname": "nothing"}
        )

    def test_search_results(self):
        self.response(filename="getseries.xml")
        results = self.tvdb.search("chuck")

        self.requests.get.assert_called_once_with(
            "http://thetvdb.com/api/GetSeries.php", params={"seriesname": "chuck"}
        )
        self.assertEqual(len(results), 7)

    def test_get_series_by_id_requires_api_key(self):
        with self.assertRaises(APIKeyRequiredError):
            self.tvdb.get_series_by_id(1111)

    def test_get_episode_by_id_requires_api_key(self):
        with self.assertRaises(APIKeyRequiredError):
            self.tvdb.get_episode_by_id(1111)

    def test_get_episode_requires_api_key(self):
        with self.assertRaises(APIKeyRequiredError):
            self.tvdb.get_episode(80348, 1, 1)
Beispiel #2
0
 def setUp(self):
     super(TvDBSearchResultTestCase, self).setUp()
     self.response(filename="getseries.xml")
     tvdb = TvDB(api_key="123456789")
     results = tvdb.search("chuck")
     self.result = results[0]