Example #1
0
 def test_sanity_check_info(self, m):
     messages = SanityCheckMessages()
     messages.info("Some info")
     m.return_value = messages
     self.assertEqual(tasks.sanity_check(),
                      "Sanity check exited with infos. See log.")
     m.assert_called_once()
Example #2
0
 def test_sanity_check_warning(self, m):
     messages = SanityCheckMessages()
     messages.warning("Some warning")
     m.return_value = messages
     self.assertEqual(tasks.sanity_check(),
                      "Sanity check exited with warnings. See log.")
     m.assert_called_once()
Example #3
0
 def test_warning(self):
     messages = SanityCheckMessages()
     messages.warning("Something is wrong")
     self.assertEqual(len(messages), 1)
     self.assertFalse(messages.has_error())
     self.assertTrue(messages.has_warning())
     with self.assertLogs() as capture:
         messages.log_messages()
         self.assertEqual(len(capture.output), 1)
         self.assertEqual(capture.records[0].levelno, logging.WARNING)
         self.assertEqual(capture.records[0].message, "Something is wrong")
Example #4
0
 def test_info(self):
     messages = SanityCheckMessages()
     messages.info("Something might be wrong")
     self.assertEqual(len(messages), 1)
     self.assertFalse(messages.has_error())
     self.assertFalse(messages.has_warning())
     with self.assertLogs() as capture:
         messages.log_messages()
         self.assertEqual(len(capture.output), 1)
         self.assertEqual(capture.records[0].levelno, logging.INFO)
         self.assertEqual(capture.records[0].message,
                          "Something might be wrong")
Example #5
0
 def test_no_messages(self):
     messages = SanityCheckMessages()
     self.assertEqual(len(messages), 0)
     self.assertFalse(messages.has_error())
     self.assertFalse(messages.has_warning())
     with self.assertLogs() as capture:
         messages.log_messages()
         self.assertEqual(len(capture.output), 1)
         self.assertEqual(capture.records[0].levelno, logging.INFO)
         self.assertEqual(capture.records[0].message,
                          "Sanity checker detected no issues.")
Example #6
0
 def test_sanity_check_error(self, m):
     messages = SanityCheckMessages()
     messages.error("Some error")
     m.return_value = messages
     self.assertRaises(SanityCheckFailedException, tasks.sanity_check)
     m.assert_called_once()
Example #7
0
 def test_sanity_check_success(self, m):
     m.return_value = SanityCheckMessages()
     self.assertEqual(tasks.sanity_check(), "No issues detected.")
     m.assert_called_once()