Example #1
0
 def test_logging_dictConfig(self, m_logging_config, config):
     message_broker._configure_logging(config)
     if "publisher" in config["logging"]:
         m_logging_config.dictConfig.assert_called_once_with(
             config["logging"]["publisher"])
     else:
         m_logging_config.dictConfig.assert_called_once_with(
             config["logging"])
Example #2
0
 def test_zmq_handler_formatters(self, m_logger, m_logging,
                                 m_logging_config):
     m_handler = Mock(name="m_zmq_handler",
                      spec=zmq.log.handlers.PUBHandler)
     m_logger.root = Mock(handlers=[m_handler])
     message_broker._configure_logging(self.zmq_logging_config)
     expected = {
         m_logging.DEBUG: m_logging.Formatter("%(message)s\n"),
         m_logging.INFO: m_logging.Formatter("%(message)s\n"),
         m_logging.WARNING: m_logging.Formatter("%(message)s\n"),
         m_logging.ERROR: m_logging.Formatter("%(message)s\n"),
         m_logging.CRITICAL: m_logging.Formatter("%(message)s\n"),
     }
     assert m_handler.formatters == expected
Example #3
0
 def test_change_rotating_logger_handler_to_watched(self, m_logging_config):
     message_broker._configure_logging(self.filesystem_logging_config)
     handler = self.filesystem_logging_config["logging"]["handlers"][
         "info_text"]
     assert handler["class"] == "logging.handlers.WatchedFileHandler"
     assert "backupCount" not in handler
Example #4
0
 def test_zmq_handler_root_topic(self, m_logger, m_logging_config):
     m_handler = Mock(name="m_zmq_handler",
                      spec=zmq.log.handlers.PUBHandler)
     m_logger.root = Mock(handlers=[m_handler])
     message_broker._configure_logging(self.zmq_logging_config)
     assert m_handler.root_topic == "message_broker"
Example #5
0
 def test_msg(self, m_logging_config, config, exp_msg):
     msg = message_broker._configure_logging(config)
     assert msg == exp_msg