old_contents: """
  Tests the log message transportation mechanism.
  """
  import unittest
  import logging
  from tkp.distribute.celery.log import setup_event_listening
  from tkp.distribute.celery import celery_app
  from tkp.distribute.celery.tasks import bogus
  
  
  class MockLoggingHandler(logging.Handler):
      """Mock logging handler to check for expected logs."""
  
      def __init__(self, *args, **kwargs):
          self.reset()
          logging.Handler.__init__(self, *args, **kwargs)
  
      def emit(self, record):
          self.records.append(record)
  
      def reset(self):
          self.records = []
  
  
  class TestCelery(unittest.TestCase):
      """
      Tests related to distributing jobs using celery
      """
  
      @unittest.skip("Enable this if you have broker and worker running")
      def testRemoteTaskLogging(self):
          """
          make sure the worker log->event->client log mechanism is working.
          """
          setup_event_listening(celery_app)
          mock_handler = MockLoggingHandler()
          root_logger = logging.getLogger()
          root_logger.setLevel(logging.DEBUG)
          root_logger.addHandler(mock_handler)
          check = {logging.INFO, logging.WARNING, logging.ERROR}
          mock_handler.reset()
          mock_handler.setLevel(logging.INFO)
          result=bogus()
  
          for record in mock_handler.records:
              if record.name == 'tkp.distribute.celery.tasks':
                  self.assertTrue(record.levelno in check)
                  check.remove(record.levelno)
          self.assertFalse(len(check))
  
      def testLocalTaskLogging(self):
          """
          Logging should also work if you run it locally
          """
          setup_event_listening(celery_app)
          mock_handler = MockLoggingHandler()
          root_logger = logging.getLogger()
          root_logger.setLevel(logging.DEBUG)
          root_logger.addHandler(mock_handler)
          check = {logging.INFO, logging.WARNING, logging.ERROR, logging.DEBUG}
          mock_handler.reset()
          bogus()
          for record in mock_handler.records:
              if record.name == 'tkp.distribute.celery.tasks':
                  self.assertTrue(record.levelno in check)
                  check.remove(record.levelno)
          self.assertFalse(len(check))
new_contents: """
  Tests the log message transportation mechanism.
  """
  import unittest
  import logging
  from tkp.distribute.celery.log import setup_event_listening
  from tkp.distribute.celery import celery_app
  from tkp.distribute.celery.tasks import bogus
  
  
  class MockLoggingHandler(logging.Handler):
      """Mock logging handler to check for expected logs."""
  
      def __init__(self, *args, **kwargs):
          self.reset()
          logging.Handler.__init__(self, *args, **kwargs)
  
      def emit(self, record):
          self.records.append(record)
  
      def reset(self):
          self.records = []
  
  
  class TestCelery(unittest.TestCase):
      """
      Tests related to distributing jobs using celery
      """
  
      @unittest.skip("Enable this if you have broker and worker running")
      def testRemoteTaskLogging(self):
          """
          make sure the worker log->event->client log mechanism is working.
          """
          setup_event_listening(celery_app)
          mock_handler = MockLoggingHandler()
          root_logger = logging.getLogger()
          root_logger.setLevel(logging.DEBUG)
          root_logger.addHandler(mock_handler)
          check = {logging.INFO, logging.WARNING, logging.ERROR}
          mock_handler.reset()
          mock_handler.setLevel(logging.INFO)
          result=bogus()
  
          for record in mock_handler.records:
              if record.name == 'tkp.distribute.celery.tasks':
                  self.assertTrue(record.levelno in check)
                  check.remove(record.levelno)
          self.assertFalse(len(check))
  
  
      @unittest('somehow this fails on build server')
      def testLocalTaskLogging(self):
          """
          Logging should also work if you run it locally
          """
          setup_event_listening(celery_app)
          mock_handler = MockLoggingHandler()
          root_logger = logging.getLogger()
          root_logger.setLevel(logging.DEBUG)
          root_logger.addHandler(mock_handler)
          check = {logging.INFO, logging.WARNING, logging.ERROR, logging.DEBUG}
          mock_handler.reset()
          bogus()
          for record in mock_handler.records:
              if record.name == 'tkp.distribute.celery.tasks':
                  self.assertTrue(record.levelno in check)
                  check.remove(record.levelno)
          self.assertFalse(len(check))
subject: test if build server is triggered