Commit b3907077 authored by Scott Moser's avatar Scott Moser

reporting: fix logging reproter and tests

parent 9975e063
......@@ -35,7 +35,7 @@ class LogHandler(ReportingHandler):
else:
input_level = level
try:
level = gettattr(logging, level.upper())
level = getattr(logging, level.upper())
except:
LOG.warn("invalid level '%s', using WARN", input_level)
level = logging.WARN
......
......@@ -137,14 +137,14 @@ class TestLogHandler(TestCase):
def test_single_log_message_at_info_published(self, getLogger):
event = reporting.ReportingEvent('type', 'name', 'description')
reporting.handlers.LogHandler().publish_event(event)
self.assertEqual(1, getLogger.return_value.info.call_count)
self.assertEqual(1, getLogger.return_value.log.call_count)
@mock.patch.object(reporting.handlers.logging, 'getLogger')
def test_log_message_uses_event_as_string(self, getLogger):
event = reporting.ReportingEvent('type', 'name', 'description')
reporting.handlers.LogHandler().publish_event(event)
reporting.handlers.LogHandler(level="INFO").publish_event(event)
self.assertIn(event.as_string(),
getLogger.return_value.info.call_args[0][0])
getLogger.return_value.log.call_args[0][1])
class TestDefaultRegisteredHandler(TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment