Beispiel #1
0
 def test_oneline_format_success(self):
     m = monitor.MonitorNull("winning", {})
     with freeze_time(self.freeze_time_value):
         for _ in range(0, 6):
             m.run_test()
         m.last_result = "a " * 80
         desired = (
             "success: winning succeeded on {hostname} at  (0+00:00:00): ".
             format(hostname=util.short_hostname()) + "a " * 80)
         output = self.test_alerter.build_message(
             alerter.AlertLength.ONELINE, alerter.AlertType.SUCCESS, m)
         self.assertEqual(desired, output)
Beispiel #2
0
 def test_sms_format_success(self):
     m = monitor.MonitorNull("winning", {})
     with freeze_time(self.freeze_time_value):
         for _ in range(0, 6):
             m.run_test()
         m.last_result = "a " * 80
         self.assertEqual(
             self.test_alerter.build_message(alerter.AlertLength.SMS,
                                             alerter.AlertType.SUCCESS, m),
             "success: winning succeeded on {hostname} at (0+00:00:00): a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a..."
             .format(hostname=util.short_hostname()),
         )
Beispiel #3
0
 def test_sms_format_failure(self):
     m = monitor.MonitorFail("test", {})
     with freeze_time(self.freeze_time_value):
         m.run_test()
         self.assertEqual(
             self.test_alerter.build_message(alerter.AlertLength.SMS,
                                             alerter.AlertType.FAILURE, m),
             "failure: test failed on {hostname} at {expected_time} (0+00:00:00): This monitor always fails."
             .format(
                 hostname=util.short_hostname(),
                 expected_time=self.expected_time_string,
             ),
         )
Beispiel #4
0
 def test_full_format_success(self):
     m = monitor.MonitorNull("winning", {})
     with freeze_time(self.freeze_time_value):
         for _ in range(0, 6):
             m.run_test()
         self.assertEqual(
             self.test_alerter.build_message(alerter.AlertLength.FULL,
                                             alerter.AlertType.SUCCESS, m),
             textwrap.dedent("""
                 Monitor winning on {hostname} succeeded!
                 Recovered at: {expected_time}
                 Additional info: 
                 Description: (Monitor did not write an auto-biography.)
                 """.format(  # noqa: W291
                 hostname=util.short_hostname(),
                 expected_time=self.expected_time_string,
             )),
         )
Beispiel #5
0
 def test_full_format_failure(self):
     m = monitor.MonitorFail("test", {})
     with freeze_time(self.freeze_time_value):
         m.run_test()
         self.assertEqual(
             self.test_alerter.build_message(alerter.AlertLength.FULL,
                                             alerter.AlertType.FAILURE, m),
             textwrap.dedent("""
                 Monitor test on {hostname} failed!
                 Failed at: {expected_time} (down 0+00:00:00)
                 Virtual failure count: 1
                 Additional info: This monitor always fails.
                 Description: A monitor which always fails.
                 """.format(
                 hostname=util.short_hostname(),
                 expected_time=self.expected_time_string,
             )),
         )