LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the analysis mediator.""" | 3 """Tests for the analysis mediator.""" |
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 dfvfs.lib import definitions as dfvfs_definitions | 9 from dfvfs.lib import definitions as dfvfs_definitions |
10 from dfvfs.path import factory as path_spec_factory | 10 from dfvfs.path import factory as path_spec_factory |
11 | 11 |
12 from plaso.analysis import mediator | 12 from plaso.analysis import mediator |
13 from plaso.containers import sessions | 13 from plaso.containers import sessions |
14 from plaso.storage.fake import writer | 14 from plaso.storage.fake import writer as fake_writer |
15 | 15 |
16 from tests.analysis import test_lib | 16 from tests.analysis import test_lib |
17 | 17 |
18 | 18 |
19 class AnalysisMediatorTest(test_lib.AnalysisPluginTestCase): | 19 class AnalysisMediatorTest(test_lib.AnalysisPluginTestCase): |
20 """Tests for the analysis mediator.""" | 20 """Tests for the analysis mediator.""" |
21 | 21 |
22 def testGetDisplayNameForPathSpec(self): | 22 def testGetDisplayNameForPathSpec(self): |
23 """Tests the GetDisplayNameForPathSpec function.""" | 23 """Tests the GetDisplayNameForPathSpec function.""" |
24 session = sessions.Session() | 24 session = sessions.Session() |
25 storage_writer = writer.FakeStorageWriter(session) | 25 storage_writer = fake_writer.FakeStorageWriter(session) |
26 knowledge_base = self._SetUpKnowledgeBase() | 26 knowledge_base = self._SetUpKnowledgeBase() |
27 | 27 |
28 analysis_mediator = mediator.AnalysisMediator( | 28 analysis_mediator = mediator.AnalysisMediator( |
29 storage_writer, knowledge_base) | 29 storage_writer, knowledge_base) |
30 | 30 |
31 test_path = self._GetTestFilePath(['syslog.gz']) | 31 test_path = self._GetTestFilePath(['syslog.gz']) |
32 os_path_spec = path_spec_factory.Factory.NewPathSpec( | 32 os_path_spec = path_spec_factory.Factory.NewPathSpec( |
33 dfvfs_definitions.TYPE_INDICATOR_OS, location=test_path) | 33 dfvfs_definitions.TYPE_INDICATOR_OS, location=test_path) |
34 | 34 |
35 expected_display_name = 'OS:{0:s}'.format(test_path) | 35 expected_display_name = 'OS:{0:s}'.format(test_path) |
36 display_name = analysis_mediator.GetDisplayNameForPathSpec(os_path_spec) | 36 display_name = analysis_mediator.GetDisplayNameForPathSpec(os_path_spec) |
37 self.assertEqual(display_name, expected_display_name) | 37 self.assertEqual(display_name, expected_display_name) |
38 | 38 |
39 # TODO: add test for GetUsernameForPath. | 39 # TODO: add test for GetUsernameForPath. |
40 # TODO: add test for ProduceAnalysisReport. | 40 # TODO: add test for ProduceAnalysisReport. |
41 # TODO: add test for ProduceEventTag. | 41 # TODO: add test for ProduceEventTag. |
42 | 42 |
43 def testSignalAbort(self): | 43 def testSignalAbort(self): |
44 """Tests the SignalAbort function.""" | 44 """Tests the SignalAbort function.""" |
45 session = sessions.Session() | 45 session = sessions.Session() |
46 storage_writer = writer.FakeStorageWriter(session) | 46 storage_writer = fake_writer.FakeStorageWriter(session) |
47 knowledge_base = self._SetUpKnowledgeBase() | 47 knowledge_base = self._SetUpKnowledgeBase() |
48 | 48 |
49 analysis_mediator = mediator.AnalysisMediator( | 49 analysis_mediator = mediator.AnalysisMediator( |
50 storage_writer, knowledge_base) | 50 storage_writer, knowledge_base) |
51 | 51 |
52 analysis_mediator.SignalAbort() | 52 analysis_mediator.SignalAbort() |
53 | 53 |
54 | 54 |
55 if __name__ == '__main__': | 55 if __name__ == '__main__': |
56 unittest.main() | 56 unittest.main() |
LEFT | RIGHT |