OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """Event formatter related functions and classes for testing.""" | 2 """Event formatter related functions and classes for testing.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import unittest | 6 import unittest |
7 | 7 |
8 from plaso.formatters import interface | 8 from plaso.formatters import interface |
9 | 9 |
10 | 10 |
11 class TestEventFormatter(interface.EventFormatter): | 11 class TestEventFormatter(interface.EventFormatter): |
12 """Test event formatter.""" | 12 """Test event formatter.""" |
13 | 13 |
14 DATA_TYPE = 'test:event' | 14 DATA_TYPE = 'test:event' |
15 FORMAT_STRING = '{text}' | 15 FORMAT_STRING = '{text}' |
16 | 16 |
17 SOURCE_SHORT = 'FILE' | 17 SOURCE_SHORT = 'FILE' |
18 SOURCE_LONG = 'Weird Log File' | 18 SOURCE_LONG = 'Weird Log File' |
19 | 19 |
20 | 20 |
21 class EventFormatterTestCase(unittest.TestCase): | 21 class EventFormatterTestCase(unittest.TestCase): |
22 """The unit test case for an event formatter.""" | 22 """The unit test case for an event formatter.""" |
23 | 23 |
24 def _TestGetFormatStringAttributeNames( | 24 def _TestGetFormatStringAttributeNames( |
25 self, event_formatter, expected_attribute_names): | 25 self, event_formatter, expected_attribute_names): |
26 """Tests the GetFormatStringAttributeNames function. | 26 """Tests the GetFormatStringAttributeNames function. |
27 | 27 |
28 Args: | 28 Args: |
29 event_formatter: the event formatter (instance of EventFormatter). | 29 event_formatter (EventFormatter): event formatter under test. |
30 expected_attribute_names: list of the expected attribute names. | 30 expected_attribute_names (list[str]): expected attribute names. |
31 """ | 31 """ |
32 attribute_names = event_formatter.GetFormatStringAttributeNames() | 32 attribute_names = event_formatter.GetFormatStringAttributeNames() |
33 self.assertEqual(sorted(attribute_names), sorted(expected_attribute_names)) | 33 self.assertEqual(sorted(attribute_names), sorted(expected_attribute_names)) |
OLD | NEW |