def testIntialize(self): """Test the initialize functionality.""" path_spec = fake_path_spec.FakePathSpec(location=self._test_file) file_entry = fake_file_entry.FakeFileEntry( self._resolver_context, self._file_system, path_spec) self.assertIsNotNone(file_entry)
def testSize(self): """Test the size property.""" path_spec = fake_path_spec.FakePathSpec(location=self._test_file) file_entry = fake_file_entry.FakeFileEntry(self._resolver_context, self._file_system, path_spec) self.assertIsNotNone(file_entry) self.assertIsNone(file_entry.size)
def testName(self): """Test the name property.""" path_spec = fake_path_spec.FakePathSpec(location=self._test_file) file_entry = fake_file_entry.FakeFileEntry(self._resolver_context, self._file_system, path_spec) self.assertIsNotNone(file_entry) self.assertEqual(file_entry.name, 'testdir_fake')
def GetFileEntryByPathSpec(self, path_spec): """Retrieves a file entry for a path specification. Args: path_spec: a path specification (instance of PathSpec). Returns: A file entry (instance of vfs.FileEntry) or None. """ location = getattr(path_spec, u'location', None) if location is None: return if not self.FileEntryExistsByPathSpec(path_spec): return return fake_file_entry.FakeFileEntry(self._resolver_context, self, path_spec)
def GetFileEntryByPath(self, path): """Retrieves a file entry for a path. Args: path: a string containing the path of the file entry. Returns: A file entry (instance of vfs.FileEntry) or None. """ if path is None: return if not self.FileEntryExistsByPath(path): return path_spec = fake_path_spec.FakePathSpec(location=path) return fake_file_entry.FakeFileEntry(self._resolver_context, self, path_spec)
def GetFileEntryByPath(self, path): """Retrieves a file entry for a path. Args: path (str): path of the file entry. Returns: FakeFileEntry: a file entry or None if not available. """ if path is None: return None file_entry_type, _ = self._paths.get(path, (None, None)) if not file_entry_type: return None path_spec = fake_path_spec.FakePathSpec(location=path) return fake_file_entry.FakeFileEntry( self._resolver_context, self, path_spec, file_entry_type=file_entry_type)