class ShowTest(unittest.TestCase): show = Show('house m.d.') show_error = Show('farscape') def test_show_still_running(self): assert self.show.ended == 0 def test_get_season(self): season = self.show.season(1) assert len(season) == 22 assert season.episode(1).title == 'Pilot' def test_get_next_episode_from_dead_show(self): try: self.show_error.next_episode except Exception, e: assert isinstance(e, ShowHasEnded)
def test_get_finale(self): assert self.season.finale.number == 24 # and now the execption: # NOTE: this test may break, when the season finale actually gets # announced try: Show('house').current_season.finale except Exception, e: assert isinstance(e, FinaleMayNotBeAnnouncedYet)
class EpisodeTest(unittest.TestCase): ep = Show('house m.d.').season(3).episode(6) def test_show(self): assert self.ep.show == 'House' def test_season(self): assert self.ep.season == 3 def test_num(self): assert self.ep.number == 6 def test_airdate(self): assert self.ep.airdate == date(2006, 11, 07) def test_title(self): assert self.ep.title == 'Que Sera Sera' def test_link(self): assert self.ep.link == \ 'http://www.tvrage.com/House/episodes/461013' def test_summary_old(self): s = "An immensely overweight man is brought in after he's found at"\ +" home in a coma. Upon regaining consciousness, he demands"\ +" to be released. When Cameron comes up with a way to force"\ +" him to stay, the man insists the find a reason for his"\ +" illness other than his obesity. Meanwhile, Det. Tritter"\ +" arrests House, searches his home, and questions his"\ +" co-workers about his Vicodin usage." assert self.ep.summary == s def test_summary_new(self): ep = Show('chaos').season(1).episode(8) s = 'The agents go against orders to capture an arms dealer, but their'\ +' actions trouble Rick who must decide whether to report their'\ +' unauthorized activities to the CIA director.' assert ep.summary == s
class SeasonTest(unittest.TestCase): season = Show('house m.d.').season(3) def test_get_episode(self): assert self.season.episode(1).number == 1 assert self.season.episode(6).number == 6 assert self.season.episode(24).number == 24 def test_get_premiere(self): ep = self.season.premiere assert ep.number == 1 def test_get_finale(self): assert self.season.finale.number == 24 # and now the execption: # NOTE: this test may break, when the season finale actually gets # announced try: Show('house').current_season.finale except Exception, e: assert isinstance(e, FinaleMayNotBeAnnouncedYet)
def test_non_existant_show_raises_proper_exception(self): try: Show('yaddayadda') except Exception, e: assert isinstance(e, ShowNotFound) assert e.value == 'yaddayadda'
def test_get_latest_ep(self): today = date.today() ep = Show('FlashForward').latest_episode assert ep.airdate <= today assert ep.title == 'Future Shock'
def test_summary_new(self): ep = Show('chaos').season(1).episode(8) s = 'The agents go against orders to capture an arms dealer, but their'\ +' actions trouble Rick who must decide whether to report their'\ +' unauthorized activities to the CIA director.' assert ep.summary == s
def test_show_with_missing_seasons_doesnt_mess_up_season_count(self): # Seasons 39 - 47 are missing s = Show(u'House Hunters') assert s.seasons >= 48