OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """Tests for the file system implementation using the tarfile.""" | 3 """Tests for the file system implementation using the tarfile.""" |
4 | 4 |
5 import unittest | 5 import unittest |
6 | 6 |
7 from dfvfs.path import os_path_spec | 7 from dfvfs.path import os_path_spec |
8 from dfvfs.path import tar_path_spec | 8 from dfvfs.path import tar_path_spec |
9 from dfvfs.resolver import context | 9 from dfvfs.resolver import context |
10 from dfvfs.vfs import tar_file_system | 10 from dfvfs.vfs import tar_file_system |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 def testOpenAndClose(self): | 27 def testOpenAndClose(self): |
28 """Test the open and close functionality.""" | 28 """Test the open and close functionality.""" |
29 file_system = tar_file_system.TARFileSystem(self._resolver_context) | 29 file_system = tar_file_system.TARFileSystem(self._resolver_context) |
30 self.assertIsNotNone(file_system) | 30 self.assertIsNotNone(file_system) |
31 | 31 |
32 file_system.Open(self._tar_path_spec) | 32 file_system.Open(self._tar_path_spec) |
33 | 33 |
34 file_system.Close() | 34 file_system.Close() |
35 | 35 |
| 36 @shared_test_lib.skipUnlessHasTestFile([u'missing_directory_entries.tar']) |
36 def testFileEntryExistsByPathSpec(self): | 37 def testFileEntryExistsByPathSpec(self): |
37 """Test the file entry exists by path specification functionality.""" | 38 """Test the file entry exists by path specification functionality.""" |
38 file_system = tar_file_system.TARFileSystem(self._resolver_context) | 39 file_system = tar_file_system.TARFileSystem(self._resolver_context) |
39 self.assertIsNotNone(file_system) | 40 self.assertIsNotNone(file_system) |
40 | 41 |
41 file_system.Open(self._tar_path_spec) | 42 file_system.Open(self._tar_path_spec) |
42 | 43 |
43 path_spec = tar_path_spec.TARPathSpec( | 44 path_spec = tar_path_spec.TARPathSpec( |
44 location=u'/syslog', parent=self._os_path_spec) | 45 location=u'/syslog', parent=self._os_path_spec) |
45 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) | 46 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) |
(...skipping 17 matching lines...) Expand all Loading... |
63 path_spec = tar_path_spec.TARPathSpec( | 64 path_spec = tar_path_spec.TARPathSpec( |
64 location=u'/File System', parent=test_file_path_spec) | 65 location=u'/File System', parent=test_file_path_spec) |
65 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) | 66 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) |
66 | 67 |
67 path_spec = tar_path_spec.TARPathSpec( | 68 path_spec = tar_path_spec.TARPathSpec( |
68 location=u'/File System/Recordings', parent=test_file_path_spec) | 69 location=u'/File System/Recordings', parent=test_file_path_spec) |
69 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) | 70 self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec)) |
70 | 71 |
71 file_system.Close() | 72 file_system.Close() |
72 | 73 |
| 74 @shared_test_lib.skipUnlessHasTestFile([u'missing_directory_entries.tar']) |
73 def testGetFileEntryByPathSpec(self): | 75 def testGetFileEntryByPathSpec(self): |
74 """Tests the GetFileEntryByPathSpec function.""" | 76 """Tests the GetFileEntryByPathSpec function.""" |
75 file_system = tar_file_system.TARFileSystem(self._resolver_context) | 77 file_system = tar_file_system.TARFileSystem(self._resolver_context) |
76 self.assertIsNotNone(file_system) | 78 self.assertIsNotNone(file_system) |
77 | 79 |
78 file_system.Open(self._tar_path_spec) | 80 file_system.Open(self._tar_path_spec) |
79 | 81 |
80 path_spec = tar_path_spec.TARPathSpec( | 82 path_spec = tar_path_spec.TARPathSpec( |
81 location=u'/syslog', parent=self._os_path_spec) | 83 location=u'/syslog', parent=self._os_path_spec) |
82 file_entry = file_system.GetFileEntryByPathSpec(path_spec) | 84 file_entry = file_system.GetFileEntryByPathSpec(path_spec) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 file_entry = file_system.GetRootFileEntry() | 128 file_entry = file_system.GetRootFileEntry() |
127 | 129 |
128 self.assertIsNotNone(file_entry) | 130 self.assertIsNotNone(file_entry) |
129 self.assertEqual(file_entry.name, u'') | 131 self.assertEqual(file_entry.name, u'') |
130 | 132 |
131 file_system.Close() | 133 file_system.Close() |
132 | 134 |
133 | 135 |
134 if __name__ == '__main__': | 136 if __name__ == '__main__': |
135 unittest.main() | 137 unittest.main() |
OLD | NEW |