def setUp(self): nagctl.conf["host"] = None nagctl.conf["service"] = None nagctl.hosts = [] nagctl.services = [] nagctl.hosts.append( nagctl.Host({ "host_name": "worker0", "hostgroups": "group0" })) nagctl.hosts.append( nagctl.Host({ "host_name": "worker1", "hostgroups": "group1" })) nagctl.hosts.append( nagctl.Host({ "host_name": "database", "hostgroups": "group0, group1" })) nagctl.services.append( nagctl.Service({ "service_description": "queue0", "hostgroup_name": "group0" })) nagctl.services.append( nagctl.Service({ "service_description": "queue1", "hostgroup_name": "group1" })) nagctl.services.append( nagctl.Service({ "service_description": "load", "hostgroup_name": "group0, group1" }))
def test_getServiceList(self): """getServiceList: return a list of service objects""" h0 = nagctl.Host({}) self.objects.addHost(h0) self.assertEqual(self.objects.getServiceList(0), []) s0 = nagctl.Service({}) self.objects.addService(s0) self.assertEqual(self.objects.getServiceList(0), [s0]) s1 = nagctl.Service({}) self.objects.addService(s1) self.assertEqual(self.objects.getServiceList(0), [s0, s1])
def test_addService(self): """addService: append service objects to internal list""" h0 = nagctl.Host({}) self.objects.addHost(h0) self.assertEqual(self.objects.getServiceList(0), []) s0 = nagctl.Service({}) self.objects.addService(s0) self.assertEqual(self.objects.getServiceList(0), [s0]) s1 = nagctl.Service({}) self.objects.addService(s1) self.assertEqual(self.objects.getServiceList(0), [s0, s1])
def test_addService_none(self): """addService: raise IndexError when adding service to non-existent host""" s0 = nagctl.Service({}) self.assertRaises(IndexError, self.objects.addService, s0)
def setUp(self): self.s = nagctl.Service({})
def setUp(self): self.o = nagctl.Object({}) self.h = nagctl.Host({}) self.s = nagctl.Service({})