OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the Zeitgeist activity database plugin.""" | 3 """Tests for the Zeitgeist activity database plugin.""" |
4 | 4 |
5 from __future__ import unicode_literals | 5 from __future__ import unicode_literals |
6 | 6 |
7 import unittest | 7 import unittest |
8 | 8 |
9 from plaso.formatters import zeitgeist as _ # pylint: disable=unused-import | 9 from plaso.formatters import zeitgeist as _ # pylint: disable=unused-import |
10 from plaso.lib import timelib | |
11 from plaso.parsers.sqlite_plugins import zeitgeist | 10 from plaso.parsers.sqlite_plugins import zeitgeist |
12 | 11 |
13 from tests import test_lib as shared_test_lib | 12 from tests import test_lib as shared_test_lib |
14 from tests.parsers.sqlite_plugins import test_lib | 13 from tests.parsers.sqlite_plugins import test_lib |
15 | 14 |
16 | 15 |
17 class ZeitgeistActivityDatabasePluginTest(test_lib.SQLitePluginTestCase): | 16 class ZeitgeistActivityDatabasePluginTest(test_lib.SQLitePluginTestCase): |
18 """Tests for the Zeitgeist activity database plugin.""" | 17 """Tests for the Zeitgeist activity database plugin.""" |
19 | 18 |
20 @shared_test_lib.skipUnlessHasTestFile(['activity.sqlite']) | 19 @shared_test_lib.skipUnlessHasTestFile(['activity.sqlite']) |
21 def testProcess(self): | 20 def testProcess(self): |
22 """Tests the Process function.""" | 21 """Tests the Process function.""" |
23 plugin = zeitgeist.ZeitgeistActivityDatabasePlugin() | 22 plugin = zeitgeist.ZeitgeistActivityDatabasePlugin() |
24 storage_writer = self._ParseDatabaseFileWithPlugin( | 23 storage_writer = self._ParseDatabaseFileWithPlugin( |
25 ['activity.sqlite'], plugin) | 24 ['activity.sqlite'], plugin) |
26 | 25 |
27 # The sqlite database contains 44 events. | 26 # The sqlite database contains 44 events. |
28 self.assertEqual(storage_writer.number_of_events, 44) | 27 self.assertEqual(storage_writer.number_of_events, 44) |
29 | 28 |
30 events = list(storage_writer.GetEvents()) | 29 events = list(storage_writer.GetEvents()) |
31 | 30 |
32 # Check the first event. | 31 # Check the first event. |
33 event = events[0] | 32 event = events[0] |
34 | 33 |
35 expected_timestamp = timelib.Timestamp.CopyFromString( | 34 self.CheckTimestamp(event.timestamp, '2013-10-22 08:53:19.477000') |
36 '2013-10-22 08:53:19.477') | |
37 self.assertEqual(event.timestamp, expected_timestamp) | |
38 | 35 |
39 expected_subject_uri = 'application://rhythmbox.desktop' | 36 self.assertEqual(event.subject_uri, 'application://rhythmbox.desktop') |
40 self.assertEqual(event.subject_uri, expected_subject_uri) | |
41 | 37 |
42 expected_message = 'application://rhythmbox.desktop' | 38 expected_message = 'application://rhythmbox.desktop' |
43 self._TestGetMessageStrings(event, expected_message, expected_message) | 39 self._TestGetMessageStrings(event, expected_message, expected_message) |
44 | 40 |
45 | 41 |
46 if __name__ == '__main__': | 42 if __name__ == '__main__': |
47 unittest.main() | 43 unittest.main() |
OLD | NEW |