def test_008_normalizer_multiple_paths(self): """ Verify we can can deal with multiple normalizer paths. """ fdir = tempfile.mkdtemp() sdir = tempfile.mkdtemp() for f in os.listdir(self.normalizer_path): path_f = os.path.join(self.normalizer_path, f) if os.path.isfile(path_f): shutil.copyfile(path_f, os.path.join(fdir, f)) shutil.move(os.path.join(fdir, 'postfix.xml'), os.path.join(sdir, 'postfix.xml')) ln = LogNormalizer([fdir, sdir]) source = ln.get_normalizer_source('postfix-0.99') self.assertEquals( XMLfromstring(source).getroottree().getroot().get('name'), 'postfix') self.assertTrue( ln.get_normalizer_path('postfix-0.99').__contains__( os.path.basename(sdir))) self.assertTrue( ln.get_normalizer_path('syslog-1.0').__contains__( os.path.basename(fdir))) xml_src = ln.get_normalizer_source('syslog-1.0') os.unlink(os.path.join(fdir, 'syslog.xml')) ln.reload() self.assertRaises(ValueError, ln.get_normalizer_path, 'syslog-1.0') ln.update_normalizer(xml_src, dir_path=sdir) self.assertTrue( ln.get_normalizer_path('syslog-1.0').__contains__( os.path.basename(sdir))) shutil.rmtree(fdir) shutil.rmtree(sdir)
def test_009_normalizer_multiple_version(self): """ Verify we can can deal with a normalizer with more than one version. """ fdir = tempfile.mkdtemp() shutil.copyfile(os.path.join(self.normalizer_path, 'postfix.xml'), os.path.join(fdir, 'postfix.xml')) # Change normalizer version in fdir path xml = parse(os.path.join(fdir, 'postfix.xml')) xmln = xml.getroot() xmln.set('version', '1.0') xml.write(os.path.join(fdir, 'postfix.xml')) ln = LogNormalizer([self.normalizer_path, fdir]) self.assertEquals(XMLfromstring(ln.get_normalizer_source('postfix-0.99')).getroottree().getroot().get('version'), '0.99') self.assertEquals(XMLfromstring(ln.get_normalizer_source('postfix-1.0')).getroottree().getroot().get('version'), '1.0') shutil.rmtree(fdir)
def test_009_normalizer_multiple_version(self): """ Verify we can can deal with a normalizer with more than one version. """ fdir = tempfile.mkdtemp() shutil.copyfile(os.path.join(self.normalizer_path, 'postfix.xml'), os.path.join(fdir, 'postfix.xml')) # Change normalizer version in fdir path xml = parse(os.path.join(fdir, 'postfix.xml')) xmln = xml.getroot() xmln.set('version', '1.0') xml.write(os.path.join(fdir, 'postfix.xml')) ln = LogNormalizer([self.normalizer_path, fdir]) self.assertEquals(XMLfromstring(ln.get_normalizer_source('postfix-0.99')).getroottree().getroot().get('version'), '0.99') self.assertEquals(XMLfromstring(ln.get_normalizer_source('postfix-1.0')).getroottree().getroot().get('version'), '1.0') shutil.rmtree(fdir)
def test_007_normalizer_getsource(self): """ Verify we can retreive XML source of a normalizer. """ ln = LogNormalizer(self.normalizer_path) source = ln.get_normalizer_source('syslog-1.0') self.assertEquals(XMLfromstring(source).getroottree().getroot().get('name'), 'syslog')
def test_007_normalizer_getsource(self): """ Verify we can retreive XML source of a normalizer. """ ln = LogNormalizer(self.normalizer_path) source = ln.get_normalizer_source('syslog-0.99') self.assertEquals(XMLfromstring(source).getroottree().getroot().get('name'), 'syslog')
def test_008_normalizer_multiple_paths(self): """ Verify we can can deal with multiple normalizer paths. """ fdir = tempfile.mkdtemp() sdir = tempfile.mkdtemp() for f in os.listdir(self.normalizer_path): path_f = os.path.join(self.normalizer_path, f) if os.path.isfile(path_f): shutil.copyfile(path_f, os.path.join(fdir, f)) shutil.move(os.path.join(fdir, 'postfix.xml'), os.path.join(sdir, 'postfix.xml')) ln = LogNormalizer([fdir, sdir]) source = ln.get_normalizer_source('postfix-0.99') self.assertEquals(XMLfromstring(source).getroottree().getroot().get('name'), 'postfix') self.assertTrue(ln.get_normalizer_path('postfix-0.99').__contains__(os.path.basename(sdir))) self.assertTrue(ln.get_normalizer_path('syslog-1.0').__contains__(os.path.basename(fdir))) xml_src = ln.get_normalizer_source('syslog-1.0') os.unlink(os.path.join(fdir, 'syslog.xml')) ln.reload() self.assertRaises(ValueError, ln.get_normalizer_path, 'syslog-1.0') ln.update_normalizer(xml_src, dir_path = sdir) self.assertTrue(ln.get_normalizer_path('syslog-1.0').__contains__(os.path.basename(sdir))) shutil.rmtree(fdir) shutil.rmtree(sdir)