def test_scheduleCheck_none(self): """scheduleCheck: do not generate any commands""" nagctl.conf["host"] = "worker0" nagctl.conf["service"] = "queue1" commands = nagctl.scheduleCheck(["schedule", "check", "3600"], "all") expected = [] self.assertEqual(commands, expected)
def test_scheduleCheck_service(self): """scheduleCheck: generate commands to schedule service check""" import re nagctl.conf["service"] = "load" commands = nagctl.scheduleCheck(["schedule", "check", "3600"], "service") for i in range (0, len(commands)): commands[i] = commands[i].split(";") # Check if timestamp is an integer. self.assertTrue(re.match("^\d+$", commands[i][-1])) # Remove timestamp from command list before comparing commands. commands[i] = commands[i][:-1] expected = [["SCHEDULE_SVC_CHECK", "worker0", "load"], ["SCHEDULE_SVC_CHECK", "worker1", "load"], ["SCHEDULE_SVC_CHECK", "database", "load"]] self.assertEqual(commands, expected)
def test_scheduleCheck_host(self): """scheduleCheck: generate commands to schedule host check""" import re nagctl.conf["host"] = "database" commands = nagctl.scheduleCheck(["schedule", "check", "3600"], "host") for i in range(0, len(commands)): commands[i] = commands[i].split(";") # Check if timestamp is an integer. self.assertTrue(re.match("^\d+$", commands[i][-1])) # Remove timestamp from command list before comparing commands. commands[i] = commands[i][:-1] expected = [["SCHEDULE_HOST_CHECK", "database"]] self.assertEqual(commands, expected)