def test_make_xml(self): hostname, servicename, instruction = 'MixedCase', 'Mixed Case', '/cpu/count' check = ncpacheck.NCPACheck(self.config, instruction, hostname, servicename) xml = nrdp.make_xml(check).toxml() tree = ET.fromstring(xml) servicename = tree.findall('servicename')[0] hostname = tree.findall('hostname')[0] stdout = tree.findall('output')[0] state = tree.findall('state')[0] self.assertEquals(tree.tag, 'checkresult') self.assertEquals(tree.attrib, {'type': 'service'}) self.assertEquals(servicename.text, 'Mixed Case') self.assertEquals(hostname.text, 'MixedCase') self.assertIsNotNone(stdout) self.assertIsNotNone(state) hostname, servicename, instruction = 'testing_host', '__HOST__', '/cpu/count' check = ncpacheck.NCPACheck(self.config, instruction, hostname, servicename) xml = nrdp.make_xml(check).toxml() tree = ET.fromstring(xml) hostname = tree.findall('hostname')[0] stdout = tree.findall('output')[0] state = tree.findall('state')[0] self.assertEquals(tree.tag, 'checkresult') self.assertEquals(tree.attrib, {'type': 'host'}) self.assertEquals(tree.findall('servicename'), []) self.assertEquals(hostname.text, 'testing_host') self.assertIsNotNone(stdout) self.assertIsNotNone(state)
def test_make_xml(self): hostname, servicename, instruction = 'MixedCase', 'Mixed Case', '/cpu/count' check = ncpacheck.NCPACheck(instruction, hostname, servicename) xml = nrdp.make_xml(check).toxml() tree = ET.fromstring(xml) servicename = tree.findall('servicename')[0] hostname = tree.findall('hostname')[0] stdout = tree.findall('output')[0] state = tree.findall('state')[0] self.assertEquals(tree.tag, 'checkresult') self.assertEquals(tree.attrib, {'type': 'service'}) self.assertEquals(servicename.text, 'Mixed Case') self.assertEquals(hostname.text, 'MixedCase') self.assertIsNotNone(stdout) self.assertIsNotNone(state) hostname, servicename, instruction = 'testing_host', '__HOST__', '/cpu/count' check = ncpacheck.NCPACheck(instruction, hostname, servicename) xml = nrdp.make_xml(check).toxml() tree = ET.fromstring(xml) hostname = tree.findall('hostname')[0] stdout = tree.findall('output')[0] state = tree.findall('state')[0] self.assertEquals(tree.tag, 'checkresult') self.assertEquals(tree.attrib, {'type': 'host'}) self.assertEquals(tree.findall('servicename'), []) self.assertEquals(hostname.text, 'testing_host') self.assertIsNotNone(stdout) self.assertIsNotNone(state)
def test_make_tag(self): # Here I am not using xml.dom.minidom to parse because IT SUCKS. Rather I am using xml.etree. # One day I hope to change the underlying library in NRDP to use it, until then, we only use it in the tests :( check_xml = nrdp.make_tag(u'Mixed', u'Mixed Case', {'important': 'you betcha'}).toxml() tree = ET.fromstring(check_xml) self.assertEquals(tree.tag, 'Mixed') self.assertEquals(tree.attrib, {'important': 'you betcha'}) self.assertEquals(tree.text, 'Mixed Case')
def test_make_tag(self): # Here I am not using xml.dom.minidom to parse because IT SUCKS. Rather I am using xml.etree. # One day I hope to change the underlying library in NRDP to use it, until then, we only use it in the tests :( check_xml = nrdp.make_tag(u'Mixed', u'Mixed Case', { 'important': 'you betcha' }).toxml() tree = ET.fromstring(check_xml) self.assertEquals(tree.tag, 'Mixed') self.assertEquals(tree.attrib, {'important': 'you betcha'}) self.assertEquals(tree.text, 'Mixed Case')