def test_10_final_callbacks(self): """Testing final callbacks""" normalizer = Normalizer( self.n, os.path.join(self.normalizer_path, 'common_tagTypes.xml'), os.path.join(self.normalizer_path, 'common_callBacks.xml')) self.assertTrue(['toto', 'tata'] == normalizer.finalCallbacks) self.assertTrue(normalizer.validate())
def test_10_final_callbacks(self): """Testing final callbacks""" normalizer = Normalizer(self.n, os.path.join(self.normalizer_path, 'common_tagTypes.xml'), os.path.join(self.normalizer_path, 'common_callBacks.xml')) self.assertTrue(['toto', 'tata'] == normalizer.finalCallbacks) self.assertTrue(normalizer.validate())
def normalize_samples(self, norm, name, version): """Test logparser.normalize validate for syslog normalizer.""" # open parser n = parse(open(os.path.join(self.normalizer_path, norm))) # validate DTD dtd = DTD(open(os.path.join(self.normalizer_path, 'normalizer.dtd'))) dtd.assertValid(n) # Create normalizer from xml definition normalizer = Normalizer(n, os.path.join(self.normalizer_path, 'common_tagTypes.xml'), os.path.join(self.normalizer_path, 'common_callBacks.xml')) self.assertEquals(normalizer.name, name) self.assertEquals(normalizer.version, version) self.assertTrue(normalizer.validate())
def normalize_samples(self, norm, name, version): """Test logparser.normalize validate for syslog normalizer.""" # open parser n = parse(open(os.path.join(self.normalizer_path, norm))) # validate DTD dtd = DTD(open(os.path.join(self.normalizer_path, 'normalizer.dtd'))) self.assertTrue(dtd.validate(n)) # Create normalizer from xml definition normalizer = Normalizer( n, os.path.join(self.normalizer_path, 'common_tagTypes.xml')) self.assertEquals(normalizer.name, name) self.assertEquals(normalizer.version, version) self.assertTrue(normalizer.validate())
def validate_norm(fn, nn, version, it): global norm global result # open XML parser n = parse(open(os.path.join(path, fn))) # validate DTD dtd = DTD(open(os.path.join(path, 'normalizer.dtd'))) assert dtd.validate(n) == True # Create normalizer from xml definition norm = Normalizer(n, os.path.join(path, 'common_tagTypes.xml'), os.path.join(path, 'common_callBacks.xml')) # Time normalizer validation try: assert norm.name.lower() == nn.lower() if norm.name != nn: print "Warning, %s has name attribute set to %s" % (fn, norm.name) except AssertionError: print "\n[%s]" % norm.name, "and [%s]" % nn, "don't match" return try: assert norm.version == version except AssertionError: print "\n[%s]" % norm.version, "and [%s]" % version, "don't match" return samples_amount = len( [u for u in [v.examples for v in norm.patterns.values()]]) if samples_amount <= 0: print "No samples to validate in %s" % fn return t = timeit.Timer("assert norm.validate() == True", "from __main__ import norm") s = t.timeit(it) # Normalize result against number of validated samples s = s / float(samples_amount) # Add result result.add_res(norm.name, norm.version, norm.authors, s)
def test_10_common_elements_precedence(self): """Testing callbacks priority""" normalizer = Normalizer(self.n, os.path.join(self.normalizer_path, 'common_tagTypes.xml'), os.path.join(self.normalizer_path, 'common_callBacks.xml')) self.assertTrue(normalizer.validate())
def test_10_common_elements_precedence(self): """Testing callbacks priority""" normalizer = Normalizer( self.n, os.path.join(self.normalizer_path, 'common_tagTypes.xml'), os.path.join(self.normalizer_path, 'common_callBacks.xml')) self.assertTrue(normalizer.validate())