def test_PlayerSkippingAroundWhenEntersCommBreakDoesntSkipCommercial(self): # Setup log.debug( 'Running enters comm break and user not skipping around test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn( [CommercialBreak(500, 600)]) # close to beginning = within 2 secs from start of commercial when(self.player).getTime().thenReturn(501).thenReturn(502).thenReturn( 504).thenReturn(505) # mock a valid tracker history trackerHistory = [] for x in range(499, 500): trackerHistory.append(TrackerSample(time.time() + (x - 499), x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerEntersCommBreakCloseToBeginningSkipsCommercial(self): # Setup log.debug('Running enters comm break test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn( [CommercialBreak(500, 2500)]) # close to beginning = within 2 secs from start of commercial when(self.player).getTime().thenReturn(501).thenReturn(2501) # mock a valid tracker history trackerHistory = [] for x in range(490, 501): trackerHistory.append(TrackerSample(time.time() + x, x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(1)).seekTime(any())
def test_PlayerEntersMidPointInCommBreakDoesntSkipCommercial(self): # Setup log.debug('Running enters midpoint comm break test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn( [CommercialBreak(1000, 2000)]) # player in middle of commercial when(self.player).getTime().thenReturn(1500) # mock a valid tracker history trackerHistory = [] for x in range(1490, 1500): trackerHistory.append(TrackerSample(time.time() + (x - 1490), x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_RecordingWithNoCommBreaksDoesNothing(self): # Setup log.debug('Running no comm breaks test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn([]) when(self.player).getTime().thenReturn(500) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerNeverEntersAnyCommBreaks(self): # Setup log.debug('Running never enters comm breaks test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn([CommercialBreak(100, 200), CommercialBreak(600, 700)]) when(self.player).getTime().thenReturn(500) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(2) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerNeverEntersAnyCommBreaks(self): # Setup log.debug('Running never enters comm breaks test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn( [CommercialBreak(100, 200), CommercialBreak(600, 700)]) when(self.player).getTime().thenReturn(500) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(2) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerSkippingAroundWhenEntersCommBreakDoesntSkipCommercial(self): # Setup log.debug('Running enters comm break and user not skipping around test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn([CommercialBreak(500, 600)]) # close to beginning = within 2 secs from start of commercial when(self.player).getTime().thenReturn(501).thenReturn(502).thenReturn(504).thenReturn(505) # mock a valid tracker history trackerHistory = [] for x in range(499, 500): trackerHistory.append(TrackerSample(time.time() + (x - 499), x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerEntersMidPointInCommBreakDoesntSkipCommercial(self): # Setup log.debug('Running enters midpoint comm break test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn([CommercialBreak(1000, 2000)]) # player in middle of commercial when(self.player).getTime().thenReturn(1500) # mock a valid tracker history trackerHistory = [] for x in range(1490, 1500): trackerHistory.append(TrackerSample(time.time() + (x-1490), x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(0)).seekTime(any())
def test_PlayerEntersCommBreakCloseToBeginningSkipsCommercial(self): # Setup log.debug('Running enters comm break test...') when(self.player).isPlaying().thenReturn(True) when(self.program).getCommercials().thenReturn([CommercialBreak(500, 2500)]) # close to beginning = within 2 secs from start of commercial when(self.player).getTime().thenReturn(501).thenReturn(2501) # mock a valid tracker history trackerHistory = [] for x in range(490, 501): trackerHistory.append(TrackerSample(time.time() + x, x)) when(self.tracker).getHistory(any()).thenReturn(trackerHistory) # Test skipper = TrackingCommercialSkipper(self.player, self.program) skipper.onPlayBackStarted() time.sleep(1) when(self.player).isPlaying().thenReturn(False) skipper.onPlayBackStopped() # Verify verify(self.player, times(1)).seekTime(any())