Package rekall :: Package plugins :: Package response :: Module common_test
[frames] | no frames]

Source Code for Module rekall.plugins.response.common_test

 1  import mock 
 2  from rekall import testlib 
 3  from rekall.plugins.response import common 
4 5 6 -class TestFileSpecs(testlib.RekallBaseUnitTestCase):
7
8 - def testFileSpecUnix(self):
9 test_obj = common.FileSpec("/usr/bin/ls") 10 self.assertEqual(test_obj.basename, "ls") 11 self.assertEqual(unicode(test_obj.dirname), "/usr/bin") 12 self.assertEqual(test_obj.components(), ["usr", "bin", "ls"]) 13 self.assertEqual(test_obj.os_path(), "/usr/bin/ls") 14 15 # It does not matter if the path has a / at the end or not. It 16 # still refers to the same object. 17 test_obj = common.FileSpec("/usr/bin/") 18 self.assertEqual(test_obj.basename, "bin") 19 self.assertEqual(unicode(test_obj.dirname), "/usr") 20 21 test_obj = common.FileSpec("/") 22 self.assertEqual(test_obj.basename, "") 23 self.assertEqual(unicode(test_obj.dirname), "/") 24 self.assertEqual(test_obj.components(), [])
25 26 @mock.patch("os.path.sep", "\\")
27 - def testFileSpecWindows(self):
28 """Test windows paths.""" 29 test_obj = common.FileSpec("c:\\Windows\System32\\notepad.exe", path_sep="\\") 30 self.assertEqual(test_obj.basename, "notepad.exe") 31 self.assertEqual(unicode(test_obj.dirname), "c:\\Windows\\System32") 32 self.assertEqual(test_obj.components(), ["c:", "Windows", "System32", 33 "notepad.exe"]) 34 35 self.assertEqual(test_obj.os_path(), "c:\\Windows\System32\\notepad.exe")
36
37 38 -class TestFileInformation(testlib.RekallBaseUnitTestCase):
39 - def testUnixFiles(self):
40 pass
41 42 43 if __name__ == "__main__": 44 testlib.main() 45