def test_problem_crit(self): from nagiosplugin.result import Result, Results from nagiosplugin.state import Critical from checkpkgaudit.checkpkgaudit import AuditSummary message = "found 2 vulnerable(s) pkg(s) in : ns1, ns2" results = Results() r1 = Result(Critical, '', nagiosplugin.Metric('ns1', 1)) r2 = Result(Critical, '', nagiosplugin.Metric('ns2', 1)) results.add(r1) results.add(r2) summary = AuditSummary() sum_crit = summary.problem(results) self.assertEqual(sum_crit, message)
def test_problem_unknown(self): from nagiosplugin.result import Result, Results from nagiosplugin.state import Critical, Unknown from checkpkgaudit.checkpkgaudit import AuditSummary hint = 'masterdns pkg: jail_attach(masterdns): Operation not permitted' results = Results() r1 = Result(Critical, '', nagiosplugin.Metric('met1', 1)) r2 = Result(Unknown, hint, nagiosplugin.Metric('met1', 0)) results.add(r1) results.add(r2) summary = AuditSummary() sum_unknown = summary.problem(results) self.assertEqual(sum_unknown, hint)