def test_shouldReturnUnknownWhenInputIncorrectlyFormattedErrorLogMessage(
            self):
        input_log_message = "Completed armadillo processing"
        expected_log_message = Unknown(input_log_message)

        log_message_parsed = ErrorLogMessage.parse(input_log_message)
        self.assertEqual(expected_log_message, log_message_parsed)
 def parse(cls, input_log_message):
     expected_pattern = 'I\s(\d*)\s(.*)'
     match = re.search(expected_pattern, input_log_message)
     if match:
         return InformationLogMessage(MessageType.INFO, int(match.group(1)),
                                      match.group(2))
     else:
         return Unknown(input_log_message)
Beispiel #3
0
def parse(input_log) -> LogMessage or Unknown:
    parsed_log_message = Unknown('')
    for logMessage in LogMessage.subclasses:
        parsed_log_message = logMessage.parse(input_log)
        if not isinstance(parsed_log_message, Unknown):
            return parsed_log_message

    return parsed_log_message
 def parse(cls, input_log_message):
     expected_pattern = 'W\s(\d*)\s(.*)'
     match = re.search(expected_pattern, input_log_message)
     if match:
         return WarningLogMessage(MessageType.WARNING, int(match.group(1)),
                                  match.group(2))
     else:
         return Unknown(input_log_message)
 def parse(cls, input_log_message):
     expected_pattern = 'E\s(\d*)\s(\d*)\s(.*)'
     match = re.search(expected_pattern, input_log_message)
     if match:
         return ErrorLogMessage(MessageType.ERROR, int(match.group(1)),
                                int(match.group(2)), match.group(3))
     else:
         return Unknown(input_log_message)
Beispiel #6
0
    def test_shouldReturnUnknownWhenIncorrectLogMessageIsInput(self):
        input_log_messages = [
            "Completed armadillo processing",
            "I Completed armadillo processing",
            "W Completed armadillo processing",
            "E 1 Completed armadillo processing",
            "E Completed armadillo processing",
        ]

        for input_log_message in input_log_messages:
            expected_log_message = Unknown(input_log_message)
            log_message_parsed = LogMessageParser.parse(input_log_message)
            self.assertEqual(expected_log_message, log_message_parsed)