예제 #1
0
    def test_getSeasonAndEpisode_When_match_not_found_using_original_airdate_Then_match_by_subtitle(
            self):
        # Given
        fields = {
            'title': u'WCG Ultimate Gamer',
            'subtitle': u'In The Crosshairs',
            'starttime': socketDateTime(2010, 12, 2, 22, 45, 00),
            'endtime': socketDateTime(2010, 12, 2, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'2010-09-20',  # TVRage shows date as 2010-09-16
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertEqual('2', season)
        self.assertEqual('5', episode)
예제 #2
0
    def test_getSeasonAndEpisode_NBCNightlyNews_returns_None_cuz_TVRage_throws_KeyError(
            self):
        # Given
        fields = {
            'title': u'NBC Nightly News',
            'subtitle': u'blah',
            'starttime': socketDateTime(2008, 11, 4, 23, 45, 00),
            'endtime': socketDateTime(2008, 11, 4, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'2010-07-14'
        }

        program = RecordedProgram(pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertIsNone(season)
        self.assertIsNone(episode)
예제 #3
0
    def test_getSeasonAndEpisode_try_to_cache_output(self):
        # Given
        fields = {
            'title': u'Seinfeld',
            'starttime': socketDateTime(2008, 11, 4, 23, 45, 00),
            'endtime': socketDateTime(2008, 11, 4, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'1989-07-05'
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        for i in xrange(100):  #@UnusedVariable
            # TODO Verify hitting cache < 1sec per invocation.
            #      Since tvrage api is not injected, cannot mock
            season, episode = provider.getSeasonAndEpisode(program)
            # Then
            self.assertEqual('1', season)
            self.assertEqual('1', episode)
예제 #4
0
 def test_works_with_TVProgram_not_just_RecordedProgram(self):
     data = {
         'title': u'Love and HipHop',
         'subtitle': u'',
         'category_type': 'series',
         'originalairdate': u'2011-11-21',
         'starttime': datetime.datetime(2011, 12, 8, 22),
         'endtime': datetime.datetime(2011, 12, 8, 23),
     }
     tvProgram = TVProgram(data, translator=Mock())
     tvRage = TvRageProvider(self.platform)
     season, episode = tvRage.getSeasonAndEpisode(tvProgram)
     self.assertEqual('2', season)
     self.assertEqual('2', episode)
예제 #5
0
 def test_works_with_TVProgram_not_just_RecordedProgram(self):
     data = { 
         'title'          : u'Love and HipHop',
         'subtitle'       : u'', 
         'category_type'  : 'series',
         'originalairdate': u'2011-11-21',
         'starttime'      : datetime.datetime(2011, 12, 8, 22),
         'endtime'        : datetime.datetime(2011, 12, 8, 23),
     }
     tvProgram = TVProgram(data, translator=Mock())
     tvRage = TvRageProvider(self.platform)
     season, episode = tvRage.getSeasonAndEpisode(tvProgram)
     self.assertEqual('2', season)
     self.assertEqual('2', episode)
예제 #6
0
    def test_getSeasonAndEpisode_dont_blowup_when_a_season_is_missing(self):
        fields = {
            'title': u'The Daily Show With Jon Stewart',
            'starttime': socketDateTime(2010, 12, 2, 22, 45, 00),
            'endtime': socketDateTime(2010, 12, 2, 23, 50, 00),
            'airdate': u'2005-01-04'
        }
        program = RecordedProgram(data=pdata(fields), **self.deps)
        provider = TvRageProvider(self.platform)

        # When -- Season 3 for The Daily Show with Jon Stewart is missing
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertIsNotNone(season)
        self.assertIsNotNone(episode)
예제 #7
0
 def test_getSeasonAndEpisode_dont_blowup_when_a_season_is_missing(self):
     fields = {
         'title'     : u'The Daily Show With Jon Stewart',
         'starttime' : socketDateTime(2010, 12, 2, 22, 45, 00), 
         'endtime'   : socketDateTime(2010, 12, 2, 23, 50, 00),
         'airdate'   : u'2005-01-04'
     }
     program = RecordedProgram(data=pdata(fields), **self.deps)
     provider = TvRageProvider(self.platform)
     
     # When -- Season 3 for The Daily Show with Jon Stewart is missing
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertIsNotNone(season)
     self.assertIsNotNone(episode)
예제 #8
0
 def test_getSeasonAndEpisode_Success(self):
     # Given
     fields = {
         'title'     : u'The Real World',
         'starttime' : socketDateTime(2008, 11, 4, 23, 45, 00), 
         'endtime'   : socketDateTime(2008, 11, 4, 23, 45, 00),
         'hasairdate': 1,
         'airdate'   : u'2010-07-14'
     }
     program = RecordedProgram(data=pdata(fields,P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertEqual('24', season)
     self.assertEqual('3', episode)
예제 #9
0
 def test_getSeasonAndEpisode_Success_HouseHunters(self):
     # Given
     fields = {
         'title'     : u'House Hunters',
         'starttime' : socketDateTime(2010, 12, 2, 22, 45, 00), 
         'endtime'   : socketDateTime(2010, 12, 2, 23, 50, 00),
         'hasairdate': 1,
         'airdate'   : u'2008-11-02'
     }
     program = RecordedProgram(data=pdata(fields,P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertEqual('30', season)
     self.assertEqual('2', episode)
예제 #10
0
 def test_getSeasonAndEpisode_dont_blowup_when_a_season_is_missing(self):
     # Given
     fields = {
         'title'     : u'The Daily Show With Jon Stewart',
         'starttime' : socketDateTime(2010, 12, 2, 22, 45, 00), 
         'endtime'   : socketDateTime(2010, 12, 2, 23, 50, 00),
         'hasairdate': 1,
         'airdate'   : u'2005-01-04'
     }
     program = RecordedProgram(data=pdata(fields,P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When -- Season 3 for The Daily Show with Jon Stewart is missing
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertIsNotNone(season)
     self.assertIsNotNone(episode)
예제 #11
0
 def test_getSeasonAndEpisode_When_show_not_found_Then_returns_none(self):
     # Given
     fields = {
         'title'     : u'Crap Crappity Crapola',
         'starttime' : socketDateTime(2008, 11, 4, 22, 45, 00),
         'endtime'   : socketDateTime(2008, 11, 4, 23, 50, 00),
         'hasairdate': 1,
         'airdate'   : u'2010-08-03'
     }
     program = RecordedProgram(data=pdata(fields,P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertIsNone(season)
     self.assertIsNone(episode)
예제 #12
0
 def test_getSeasonAndEpisode_try_to_cache_output(self):
     fields = {
         'title'     : u'Seinfeld',
         'starttime' : socketDateTime(2008, 11, 4, 23, 45, 00), 
         'endtime'   : socketDateTime(2008, 11, 4, 23, 50, 00),
         'airdate'   : u'1989-07-05'
     }
     program = RecordedProgram(data=pdata(fields), **self.deps)
     provider = TvRageProvider(self.platform)
     
     # When
     for i in xrange(100):  #@UnusedVariable
         # TODO Verify hitting cache < 1sec per invocation.
         #      Since tvrage api is not injected, cannot mock
         season, episode = provider.getSeasonAndEpisode(program)
         # Then
         self.assertEqual('1', season)
         self.assertEqual('1', episode)
예제 #13
0
 def test_getSeasonAndEpisode_When_match_not_found_using_original_airdate_Then_match_by_subtitle(self):
     # Given
     fields = {
         'title'     : u'WCG Ultimate Gamer',
         'subtitle'  : u'In The Crosshairs',
         'starttime' : socketDateTime(2010, 12, 2, 22, 45, 00), 
         'endtime'   : socketDateTime(2010, 12, 2, 23, 50, 00),
         'hasairdate': 1,
         'airdate'   : u'2010-09-20',   # TVRage shows date as 2010-09-16
     }
     program = RecordedProgram(data=pdata(fields,P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertEqual('2', season)
     self.assertEqual('5', episode)
예제 #14
0
 def test_getSeasonAndEpisode_NBCNightlyNews_returns_None_cuz_TVRage_throws_KeyError(self):
     # Given
     fields = {
         'title'       :u'NBC Nightly News',
         'subtitle'    :u'blah',
         'starttime'   :socketDateTime(2008, 11, 4, 23, 45, 00),
         'endtime'     :socketDateTime(2008, 11, 4, 23, 50, 00),
         'hasairdate'  :1,
         'airdate'     :u'2010-07-14'
     }
     
     program = RecordedProgram(pdata(fields, P.version()), settings=Mock(), translator=Mock(), platform=self.platform, protocol=P, conn=Mock())
     provider = TvRageProvider(self.platform)
     
     # When
     season, episode = provider.getSeasonAndEpisode(program)
     
     # Then
     self.assertIsNone(season)
     self.assertIsNone(episode)
예제 #15
0
    def test_getSeasonAndEpisode_dont_blowup_when_a_season_is_missing(self):
        # Given
        fields = {
            'title': u'The Daily Show With Jon Stewart',
            'starttime': socketDateTime(2010, 12, 2, 22, 45, 00),
            'endtime': socketDateTime(2010, 12, 2, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'2005-01-04'
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When -- Season 3 for The Daily Show with Jon Stewart is missing
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertIsNotNone(season)
        self.assertIsNotNone(episode)
예제 #16
0
    def test_getSeasonAndEpisode_Success_HouseHunters(self):
        # Given
        fields = {
            'title': u'House Hunters',
            'starttime': socketDateTime(2010, 12, 2, 22, 45, 00),
            'endtime': socketDateTime(2010, 12, 2, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'2008-11-02'
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertEqual('30', season)
        self.assertEqual('2', episode)
예제 #17
0
    def test_getSeasonAndEpisode_When_show_not_found_Then_returns_none(self):
        # Given
        fields = {
            'title': u'Crap Crappity Crapola',
            'starttime': socketDateTime(2008, 11, 4, 22, 45, 00),
            'endtime': socketDateTime(2008, 11, 4, 23, 50, 00),
            'hasairdate': 1,
            'airdate': u'2010-08-03'
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertIsNone(season)
        self.assertIsNone(episode)
예제 #18
0
    def test_getSeasonAndEpisode_Success(self):
        # Given
        fields = {
            'title': u'The Real World',
            'starttime': socketDateTime(2008, 11, 4, 23, 45, 00),
            'endtime': socketDateTime(2008, 11, 4, 23, 45, 00),
            'hasairdate': 1,
            'airdate': u'2010-07-14'
        }
        program = RecordedProgram(data=pdata(fields, P.version()),
                                  settings=Mock(),
                                  translator=Mock(),
                                  platform=self.platform,
                                  protocol=P,
                                  conn=Mock())
        provider = TvRageProvider(self.platform)

        # When
        season, episode = provider.getSeasonAndEpisode(program)

        # Then
        self.assertEqual('24', season)
        self.assertEqual('3', episode)
예제 #19
0
    def test_pound_with_threads(self):
        max = 20
        t = []
        provider = TvRageProvider(self.platform)
        fields = {
            'title': u'Love and HipHop',
            'subtitle': u'',
            'airdate': u'2011-11-21',
            'starttime': socketDateTime(2011, 12, 8, 22, 00, 00),
            'endtime': socketDateTime(2011, 12, 8, 23, 00, 00),
        }
        program = RecordedProgram(data=pdata(fields), **self.deps)

        @run_async
        def doWork(provider):
            provider.getSeasonAndEpisode(program)

        for i in xrange(max):
            t.append(doWork(provider))

        while t:
            t.pop().join()
예제 #20
0
 def assertSeasonAndEpisode(self, program, expectedSeason, expectedEpisode):
     provider = TvRageProvider(self.platform)
     season, episode = provider.getSeasonAndEpisode(program)
     self.assertEqual(expectedSeason, season)
     self.assertEqual(expectedEpisode, episode)
예제 #21
0
 def assertSeasonAndEpisode(self, program, expectedSeason, expectedEpisode):
     provider = TvRageProvider(self.platform)
     season, episode = provider.getSeasonAndEpisode(program)
     self.assertEqual(expectedSeason, season)
     self.assertEqual(expectedEpisode, episode)