How to use the dfvfs.path.fake_path_spec.FakePathSpec function in dfvfs

To help you get started, we’ve selected a few dfvfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github log2timeline / dfvfs / tests / path / fake_path_spec.py View on Github external
def testInitialize(self):
    """Tests the path specification initialization."""
    path_spec = fake_path_spec.FakePathSpec(location='/test')

    self.assertIsNotNone(path_spec)

    with self.assertRaises(ValueError):
      fake_path_spec.FakePathSpec(location='/test', parent=self._path_spec)

    with self.assertRaises(ValueError):
      fake_path_spec.FakePathSpec(location='/test', bogus='BOGUS')
github log2timeline / dfvfs / tests / helpers / source_scanner.py View on Github external
def testGetUnscannedSubNode(self):
    """Test the GetUnscannedSubNode function."""
    test_fake_path_spec = fake_path_spec.FakePathSpec(location='/')
    test_node = source_scanner.SourceScanNode(test_fake_path_spec)

    sub_node = test_node.GetUnscannedSubNode()
    self.assertIsNotNone(sub_node)
github log2timeline / dfvfs / tests / helpers / source_scanner.py View on Github external
def testHasScanNode(self):
    """Test the HasScanNode function."""
    test_fake_path_spec = fake_path_spec.FakePathSpec(location='/')
    test_context = source_scanner.SourceScannerContext()

    self.assertFalse(test_context.HasScanNode(test_fake_path_spec))

    test_context.AddScanNode(test_fake_path_spec, None)

    self.assertTrue(test_context.HasScanNode(test_fake_path_spec))
github log2timeline / dfvfs / tests / helpers / file_system_searcher.py View on Github external
def testCheckIsFile(self):
    """Test the _CheckIsFile function."""
    file_system = self._CreateTestFileSystem()

    find_spec = file_system_searcher.FindSpec(
        file_entry_types=[definitions.FILE_ENTRY_TYPE_FILE])

    path_spec = fake_path_spec.FakePathSpec(
        location='/usr/lib/python2.7/site-packages/dfvfs/__init__.py')
    file_entry = file_system.GetFileEntryByPathSpec(path_spec)

    result = find_spec._CheckIsFile(file_entry)
    self.assertTrue(result)
github log2timeline / dfvfs / tests / resolver / cache.py View on Github external
def setUp(self):
    """Sets up the needed objects used throughout the test."""
    self._path_spec = fake_path_spec.FakePathSpec(location='1')
    self._vfs_object = TestVFSObject()
github log2timeline / dfvfs / tests / vfs / file_entry.py View on Github external
def setUp(self):
    """Sets up the needed objects used throughout the test."""
    self._resolver_context = context.Context()
    self._path_spec = fake_path_spec.FakePathSpec(location='/')

    self._file_system = fake_file_system.FakeFileSystem(self._resolver_context)
    self._file_system.Open(self._path_spec)
github log2timeline / dfvfs / tests / helpers / source_scanner.py View on Github external
def testGetUnscannedScanNode(self):
    """Test the GetUnscannedScanNode function."""
    test_fake_path_spec = fake_path_spec.FakePathSpec(location='/')
    test_context = source_scanner.SourceScannerContext()

    scan_node = test_context.GetUnscannedScanNode()
    self.assertIsNone(scan_node)

    test_context.AddScanNode(test_fake_path_spec, None)

    scan_node = test_context.GetUnscannedScanNode()
    self.assertIsNotNone(scan_node)
github log2timeline / dfvfs / tests / vfs / fake_file_entry.py View on Github external
def testIntialize(self):
    """Test the __init__ function."""
    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)
github log2timeline / plaso / tests / multi_processing / worker_process.py View on Github external
def testProcessPathSpec(self):
    """Tests the _ProcessPathSpec function."""
    configuration = configurations.ProcessingConfiguration()

    test_process = worker_process.WorkerProcess(
        None, None, None, None, None, configuration, name='TestWorker')

    session = sessions.Session()
    storage_writer = self._CreateStorageWriter(session)
    knowledge_base = self._CreateKnowledgeBase()
    parser_mediator = self._CreateParserMediator(storage_writer, knowledge_base)

    path_spec = fake_path_spec.FakePathSpec(location='/test/file')

    extraction_worker = TestEventExtractionWorker()
    test_process._ProcessPathSpec(extraction_worker, parser_mediator, path_spec)
    self.assertEqual(parser_mediator._number_of_warnings, 0)

    extraction_worker = TestFailureEventExtractionWorker()
    test_process._ProcessPathSpec(extraction_worker, parser_mediator, path_spec)
    self.assertEqual(parser_mediator._number_of_warnings, 0)
    self.assertTrue(test_process._abort)

    test_process._ProcessPathSpec(None, parser_mediator, path_spec)
    self.assertEqual(parser_mediator._number_of_warnings, 1)
github log2timeline / dfvfs / dfvfs / vfs / fake_file_system.py View on Github external
"""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)
    is_root = bool(path == self.LOCATION_ROOT)
    return fake_file_entry.FakeFileEntry(
        self._resolver_context, self, path_spec,
        file_entry_type=file_entry_type, is_root=is_root)