def test_conflict(self): """Add conflicting template""" okconfig.addtemplate('www.okconfig.org', template_name="http") self.assertRaises(okconfig.OKConfigError, okconfig.addtemplate, host_name='www.okconfig.org', template_name='http')
def test_basic(self): """Add a template to a host""" okconfig.addtemplate("www.okconfig.org", template_name="http") services = Model.Service.objects.filter( host_name="www.okconfig.org", use="okc-check_http", service_description="HTTP www.okconfig.org") self.assertEquals(len(services), 1, "There can be only one")
def test_group(self): """Test adding template with group""" okconfig.addtemplate("aliased.okconfig.org", "http", group_name="webgroup") services = Model.Service.objects.filter( host_name="aliased.okconfig.org", service_description="HTTP aliased.okconfig.org", ) self.assertEqual(1, len(services), "There can be only one") self.assertEqual(services[0].contact_groups, "webgroup")
def save(self): host_name = self.cleaned_data['host_name'] templates = self.cleaned_data['templates'] force = self.cleaned_data['force'] self.filelist = [] for i in templates: self.filelist+=okconfig.addtemplate(host_name=host_name, template_name=i,force=force)
def save(self): host_name = self.cleaned_data["host_name"] templates = self.cleaned_data["templates"] force = self.cleaned_data["force"] self.filelist = [] for i in templates: self.filelist += okconfig.addtemplate(host_name=host_name, template_name=i, force=force)
def test_multiple(self): """Add multiple templates to a host""" okconfig.addtemplate('www.okconfig.org', template_name="http") okconfig.addtemplate('www.okconfig.org', template_name="linux") for use, description in [ ('okc-check_http', 'HTTP www.okconfig.org', ), ('okc-linux-check_disks', 'Disk Usage', ), ('okc-linux-check_load', 'Load', ), ('okc-linux-check_swap', 'Swap Usage', ), ]: services = Model.Service.objects.filter( host_name="www.okconfig.org", use=use, service_description=description) self.assertEqual(1, len(services), "Unable to match %s %s" % ( use, description))
def test_force(self): """Test force adding a template""" okconfig.addtemplate('www.okconfig.org', template_name="http") okconfig.addtemplate('www.okconfig.org', template_name="http", force=True)