def test_log_lvl_1_lvl2_msg(self):
     msg = 'foo'
     gr = GenericRunner(['-v'])
     with Capturing() as output:
         gr.log(msg, 2)
     self.assertEqual(output.stdout(), [], 'there should be no stdout')
     self.assertEqual(output.stderr(), [], 'there should be no stderr')
 def test_log_lvl_0_forced_msg(self):
     msg = 'foo'
     gr = GenericRunner()
     with Capturing() as output:
         gr.log(msg, 0)
     self.assertEqual(output.stdout(), [msg], 'there should be no stdout')
     self.assertEqual(output.stderr(), [], 'there should be no stderr')
 def test_empty_workload(self):
     code = 'not triggered'
     gr = GenericRunner()
     try:
         with Capturing() as output:
             gr.workload()  # also uses exit_crit()
     except SystemExit as e:
         code = e.args[0]
     self.assertEqual(code, NAG_CRITICAL, 'workload() should terminate with NAG_CRITICAL)')
     self.assertEqual(output.stdout(), ['CRIT: Plugin implementation must define a workload()!'],
                      'Printed error msg doesnt match expectation')
     self.assertEqual(output.stderr(), [], 'there should be no stderr')
 def test_url_get(self):
     html = GenericRunner().url_get('http://www.google.com')
     b = html.find('<title>Google</title>') > -1
     self.assertTrue(b, 'Google should be in text')