Example #1
0
    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
Example #2
0
    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
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
 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()
Example #6
0
 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()
Example #7
0
    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()
Example #8
0
    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()
Example #9
0
    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()
Example #10
0
    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()
Example #11
0
    def test_matchLineAsync_When_search_string_not_found_Then_callback_invoked_with_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)
            
            def mycallback(s):
                log.debug('mycallback received %s' % s)
                self.callbackResult = s
                
            scraper = LogScraper(fname)
            worker = scraper.matchLineAsync('zzz', 3, mycallback)
            worker.join()
            self.assertIsNone(self.callbackResult)
        finally:
            self.abortGrow = True
            t.join()
Example #12
0
    def test_matchLineAsync_When_search_string_not_found_Then_callback_invoked_with_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)

            def mycallback(s):
                log.debug('mycallback received %s' % s)
                self.callbackResult = s

            scraper = LogScraper(fname)
            worker = scraper.matchLineAsync('zzz', 3, mycallback)
            worker.join()
            self.assertIsNone(self.callbackResult)
        finally:
            self.abortGrow = True
            t.join()