summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_reporting.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/unittests/test_reporting.py b/tests/unittests/test_reporting.py
index 5700118f..4f4cf3a4 100644
--- a/tests/unittests/test_reporting.py
+++ b/tests/unittests/test_reporting.py
@@ -32,7 +32,7 @@ class TestReportStartEvent(TestCase):
class TestReportFinishEvent(TestCase):
- def _report_finish_event(self, result=None):
+ def _report_finish_event(self, result=reporting.status.SUCCESS):
event_name, event_description = 'my_test_event', 'my description'
reporting.report_finish_event(
event_name, event_description, result=result)
@@ -95,31 +95,32 @@ class TestReportingHandler(TestCase):
def test_no_default_publish_event_implementation(self):
self.assertRaises(NotImplementedError,
- reporting.ReportingHandler().publish_event, None)
+ reporting.handlers.ReportingHandler().publish_event,
+ None)
class TestLogHandler(TestCase):
- @mock.patch.object(reporting.logging, 'getLogger')
+ @mock.patch.object(reporting.handlers.logging, 'getLogger')
def test_appropriate_logger_used(self, getLogger):
event_type, event_name = 'test_type', 'test_name'
event = reporting.ReportingEvent(event_type, event_name, 'description')
- reporting.LogHandler().publish_event(event)
+ reporting.handlers.LogHandler().publish_event(event)
self.assertEqual(
[mock.call(
'cloudinit.reporting.{0}.{1}'.format(event_type, event_name))],
getLogger.call_args_list)
- @mock.patch.object(reporting.logging, 'getLogger')
+ @mock.patch.object(reporting.handlers.logging, 'getLogger')
def test_single_log_message_at_info_published(self, getLogger):
event = reporting.ReportingEvent('type', 'name', 'description')
- reporting.LogHandler().publish_event(event)
+ reporting.handlers.LogHandler().publish_event(event)
self.assertEqual(1, getLogger.return_value.info.call_count)
- @mock.patch.object(reporting.logging, 'getLogger')
+ @mock.patch.object(reporting.handlers.logging, 'getLogger')
def test_log_message_uses_event_as_string(self, getLogger):
event = reporting.ReportingEvent('type', 'name', 'description')
- reporting.LogHandler().publish_event(event)
+ reporting.handlers.LogHandler().publish_event(event)
self.assertIn(event.as_string(),
getLogger.return_value.info.call_args[0][0])
@@ -130,7 +131,7 @@ class TestDefaultRegisteredHandler(TestCase):
registered_items = (
reporting.instantiated_handler_registry.registered_items)
for _, item in registered_items.items():
- if isinstance(item, reporting.LogHandler):
+ if isinstance(item, reporting.handlers.LogHandler):
break
else:
self.fail('No reporting LogHandler registered by default.')