def test_matchLine_When_file_does_not_exist_Then_throws_IOError(self): fname = os.path.join(self.sandbox, 'bogus.log') scraper = LogScraper(fname) try: scraper.matchLine('ccc', 5) self.fail('Expected IOError on non-existant file') except IOError: # SUCCESS pass
def test_matchLine_When_called_in_succession_many_times_Then_doesnt_fail(self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa','bbb','ccc','xxx','yyy','zzz','jjj'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) self.assertEqual('ccc', scraper.matchLine('ccc', 5)) self.assertEqual('yyy', scraper.matchLine('yyy', 5)) self.assertEqual('jjj', scraper.matchLine('jjj', 5)) finally: self.abortGrow = True t.join()
def test_matchLine_When_called_in_succession_many_times_Then_doesnt_fail( self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile( fname, ['aaa', 'bbb', 'ccc', 'xxx', 'yyy', 'zzz', 'jjj'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) self.assertEqual('ccc', scraper.matchLine('ccc', 5)) self.assertEqual('yyy', scraper.matchLine('yyy', 5)) self.assertEqual('jjj', scraper.matchLine('jjj', 5)) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_not_found_Then_times_out_and_returns_None(self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa','bbb','ccc'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('zzz', 5) self.assertIsNone(text) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_eventually_shows_up_in_log_but_times_out_first_Then_return_None(self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa','bbb','ccc','xxx','yyy'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('yyy', 1) self.assertIsNone(text) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_found_Then_return_matching_text(self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa','bbb','ccc','xxx','yyy'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('xxx', 10) print 'text = %s ' % text self.assertEqual('xxx',text) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_not_found_Then_times_out_and_returns_None( self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa', 'bbb', 'ccc'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('zzz', 5) self.assertIsNone(text) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_eventually_shows_up_in_log_but_times_out_first_Then_return_None( self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa', 'bbb', 'ccc', 'xxx', 'yyy'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('yyy', 1) self.assertIsNone(text) finally: self.abortGrow = True t.join()
def test_matchLine_When_search_string_found_Then_return_matching_text( self): fname = os.path.join(self.sandbox, 'xbmc.log') try: t = self.growFile(fname, ['aaa', 'bbb', 'ccc', 'xxx', 'yyy'], 1) while not os.path.exists(fname): time.sleep(1) scraper = LogScraper(fname) text = scraper.matchLine('xxx', 10) print 'text = %s ' % text self.assertEqual('xxx', text) finally: self.abortGrow = True t.join()