Exemple #1
0
  def test_FormatTimestamp(self):
    """Tests the __FormatTimestamp function."""
    output_mediator = self._CreateOutputMediator()
    formatting_helper = tln.TLNFieldFormattingHelper(output_mediator)

    event, event_data, event_data_stream = (
        containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))
    timestamp_string = formatting_helper._FormatTimestamp(
        event, event_data, event_data_stream)

    self.assertEqual(timestamp_string, '1340821021')
Exemple #2
0
  def testFormatNotes(self):
    """Tests the _FormatNotes function."""
    output_mediator = self._CreateOutputMediator()
    formatting_helper = tln.TLNFieldFormattingHelper(output_mediator)

    event, event_data, event_data_stream = (
        containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))
    notes_string = formatting_helper._FormatNotes(
        event, event_data, event_data_stream)

    self.assertEqual(
        notes_string, 'File: OS: /var/log/syslog.1 inode: 12345678')
Exemple #3
0
  def testFormatDescription(self):
    """Tests the _FormatDescription function."""
    output_mediator = self._CreateOutputMediator()

    formatters_directory_path = self._GetTestFilePath(['formatters'])
    output_mediator.ReadMessageFormattersFromDirectory(
        formatters_directory_path)

    formatting_helper = tln.TLNFieldFormattingHelper(output_mediator)

    event, event_data, event_data_stream = (
        containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))

    description_string = formatting_helper._FormatDescription(
        event, event_data, event_data_stream)

    expected_description_string = (
        '2012-06-27T18:17:01.000000+00:00; '
        'Unknown Time; '
        'Reporter <CRON> PID: |8442| (pam_unix(cron:session): session closed '
        'for user root)')
    self.assertEqual(description_string, expected_description_string)
Exemple #4
0
    def testFormatDescription(self):
        """Tests the _FormatDescription function."""
        output_mediator = self._CreateOutputMediator()
        formatting_helper = tln.TLNFieldFormattingHelper(output_mediator)

        event, event_data, event_data_stream = (
            containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))

        formatters_manager.FormattersManager.RegisterFormatter(
            formatters_test_lib.TestEventFormatter)

        try:
            description_string = formatting_helper._FormatDescription(
                event, event_data, event_data_stream)
        finally:
            formatters_manager.FormattersManager.DeregisterFormatter(
                formatters_test_lib.TestEventFormatter)

        expected_description_string = (
            '2012-06-27T18:17:01+00:00; '
            'Unknown Time; '
            'Reporter <CRON> PID: |8442| (pam_unix(cron:session): session closed '
            'for user root)')
        self.assertEqual(description_string, expected_description_string)