def test_verbose_debug_when_emit(): # Given collectd = mock_collectd() handler = CollectdLogHandler(collectd=collectd) handler.verbose = True record = make_record(msg="message", level=logging.DEBUG) # When an info record is emitted handler.emit(record=record) # Then info hook is called collectd.info.assert_called_once_with("message")
def test_non_verbose_when_info(): # Given collectd = mock_collectd() handler = CollectdLogHandler(collectd=collectd) handler.verbose = False logger = logging.Logger('some_logger') logger.addHandler(handler) # When debug is called logger.debug('Say cheese: %s %d', 'string', 10) # Then debug hook is called collectd.debug.assert_called_once_with('Say cheese: string 10') collectd.info.assert_not_called()