Ejemplo n.º 1
0
def fake_log_message(message):
    return LogMessage.objects.create(
        datetime=IMLDateTime.utcnow(),
        message=message,
        severity=0,
        facility=0,
        tag="",
        message_class=LogMessage.get_message_class(message))
    def test_classification(self):
        '''
        Test the classification code correctly classfies messages.
        '''

        test_messages = {
            'Lustre: Lustre output here': MessageClass.LUSTRE,
            'LustreError: Lustre output here': MessageClass.LUSTRE_ERROR,
            '[NOT A TIME STAMP ] Lustre: Lustre output here':
            MessageClass.NORMAL,
            '[1234567A89] LustreError: Not A Time Stamp': MessageClass.NORMAL,
            '[123456789.123456789A] LustreError: Not A Time Stamp':
            MessageClass.NORMAL,
            'Nothing to see here': MessageClass.NORMAL
        }

        for with_timestamp in [False, True]:
            for test_message, message_class in test_messages.iteritems():
                test_message = ('[9830337.7944560] '
                                if with_timestamp else '') + test_message

                self.assertEqual(LogMessage.get_message_class(test_message),
                                 message_class, test_message)
Ejemplo n.º 3
0
    def test_classification(self):
        """
        Test the classification code correctly classfies messages.
        """

        test_messages = {
            "Lustre: Lustre output here": MessageClass.LUSTRE,
            "LustreError: Lustre output here": MessageClass.LUSTRE_ERROR,
            "[NOT A TIME STAMP ] Lustre: Lustre output here":
            MessageClass.NORMAL,
            "[1234567A89] LustreError: Not A Time Stamp": MessageClass.NORMAL,
            "[123456789.123456789A] LustreError: Not A Time Stamp":
            MessageClass.NORMAL,
            "Nothing to see here": MessageClass.NORMAL,
        }

        for with_timestamp in [False, True]:
            for test_message, message_class in test_messages.iteritems():
                test_message = ("[9830337.7944560] "
                                if with_timestamp else "") + test_message

                self.assertEqual(LogMessage.get_message_class(test_message),
                                 message_class, test_message)