def test_read_actual_message_with_lots_of_whitespace(self): validator = ExtraWhitespaceValidator(self) parser = Parser(validator) parser.read(EXTRA_WHITESPACE) self.assertTrue(validator.called) validator.validate()
def test_read_actual_message(self): validator = RsyslogMessageValidator(self) parser = Parser(validator) parser.read(ACTUAL_MESSAGE) self.assertTrue(validator.called) validator.validate()
def test_read_message_with_no_octet_count(self): validator = NoOctetCountValidator(self) parser = Parser(validator) parser.read(ACTUAL_MESSAGE_NO_OCTET_COUNT) self.assertTrue(validator.called) validator.validate()
def performance(duration=10, print_output=True): validator = MessageValidator(None) parser = Parser(validator) runs = 0 then = time.time() while time.time() - then < duration: parser.read(HAPPY_PATH_MESSAGE) runs += 1 if print_output: print('Ran {} times in {} seconds for {} runs per second.'.format( runs, duration, runs / float(duration)))
def test_short_octet_count(self): validator = MessageValidator(self) parser = Parser(validator) with self.assertRaises(ParsingError): parser.read(SHORT_OCTET_COUNT)
def test_too_long_octet_count(self): validator = MessageValidator(self) parser = Parser(validator) with self.assertRaises(ParsingError): parser.read(TOO_LONG_OCTET_COUNT)