def test_get(self): """Provided the show id, you should be able to get the show object""" api = TVDB("B43FF87DE395DF56") show = api.get(79349, "en") self.assertEqual(show.SeriesName, "Dexter") self.assertEqual(show.id, 79349)
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(79349, "en") # Load the series Dexter show.update() self.assertEqual(len(show.actor_objects), 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)
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')
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)
def test_insensitive_attributes(self): """If selected, it should be possible to access the attributes in a case insensitive manner.""" api = TVDB("B43FF87DE395DF56", banners=True, ignore_case=True) show = api.get(79349, "en") # Load the series Dexter show.update() banner = show.banner_objects[0] for a in dir(banner): self.assertTrue(hasattr(banner, a)) self.assertTrue(hasattr(banner, a.lower())) self.assertTrue(hasattr(banner, a.upper()))
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(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()))
def test_actor_attributes(self): """ The attributes of the Actors class should be correct """ api = TVDB("B43FF87DE395DF56", actors=True) show = api.get(79349, "en") # Load the series Dexter show.update() actor = show.actor_objects[0] self.assertEqual(hasattr(actor, "id"), True) self.assertEqual(hasattr(actor, "Image"), True) self.assertEqual(hasattr(actor, "Name"), True) self.assertEqual(hasattr(actor, "Role"), True) self.assertEqual(hasattr(actor, "SortOrder"), True) self.assertEqual(hasattr(actor, "image_url"), True) self.assertEqual(len(dir(actor)), 6)
def setUp(self): api = TVDB("B43FF87DE395DF56", actors=True) self.show = api.get(79349, "en") # Load the series Dexter self.show.update()
def _getShow(self, _banners=True): api = TVDB("B43FF87DE395DF56", banners=_banners) show = api.get(79349, "en") # Load the series Dexter show.update() return show