Skip to content

Commit

Permalink
Changed tests to use preferred back-ends
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Nov 5, 2020
1 parent 080eed0 commit 6a2dec5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tests/file_io/apfs_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from dfvfs.path import factory as path_spec_factory
from dfvfs.resolver import context

from tests.file_io import test_lib
from tests import test_lib as shared_test_lib


class APFSFileTest(test_lib.ImageFileTestCase):
class APFSFileTest(shared_test_lib.BaseTestCase):
"""Tests the file-like object implementation using pyfsapfs.file_entry."""

_IDENTIFIER_ANOTHER_FILE = 21
Expand Down Expand Up @@ -66,7 +66,7 @@ def testOpenCloseLocation(self):
path_spec.parent = None

with self.assertRaises(errors.PathSpecError):
self._TestOpenCloseLocation(path_spec)
file_object.open(path_spec=path_spec)

def testSeek(self):
"""Test the seek functionality."""
Expand Down
6 changes: 3 additions & 3 deletions tests/file_io/ext_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from dfvfs.path import factory as path_spec_factory
from dfvfs.resolver import context

from tests.file_io import test_lib
from tests import test_lib as shared_test_lib


class EXTFileTest(test_lib.ImageFileTestCase):
class EXTFileTest(shared_test_lib.BaseTestCase):
"""Tests the file-like object implementation using pyfsext.file_entry."""

_IDENTIFIER_ANOTHER_FILE = 15
Expand Down Expand Up @@ -63,7 +63,7 @@ def testOpenCloseLocation(self):
path_spec.parent = None

with self.assertRaises(errors.PathSpecError):
self._TestOpenCloseLocation(path_spec)
file_object.open(path_spec=path_spec)

def testSeek(self):
"""Test the seek functionality."""
Expand Down
6 changes: 3 additions & 3 deletions tests/file_io/hfs_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from dfvfs.path import factory as path_spec_factory
from dfvfs.resolver import context

from tests.file_io import test_lib
from tests import test_lib as shared_test_lib


class HFSFileTest(test_lib.ImageFileTestCase):
class HFSFileTest(shared_test_lib.BaseTestCase):
"""Tests the file-like object implementation using pyfshfs.file_entry."""

_IDENTIFIER_ANOTHER_FILE = 21
Expand Down Expand Up @@ -63,7 +63,7 @@ def testOpenCloseLocation(self):
path_spec.parent = None

with self.assertRaises(errors.PathSpecError):
self._TestOpenCloseLocation(path_spec)
file_object.open(path_spec=path_spec)

def testSeek(self):
"""Test the seek functionality."""
Expand Down
37 changes: 23 additions & 14 deletions tests/file_io/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
from dfvfs.file_io import ntfs_file_io
from dfvfs.file_io import tsk_file_io
from dfvfs.file_io import tsk_partition_file_io
from dfvfs.lib import definitions
from dfvfs.lib import errors
from dfvfs.path import factory as path_spec_factory
from dfvfs.path import ntfs_path_spec
from dfvfs.path import tsk_path_spec
from dfvfs.path import tsk_partition_path_spec
from dfvfs.resolver import context
from dfvfs.resolver import resolver

from tests import test_lib as shared_test_lib

Expand All @@ -33,9 +36,11 @@ def _TestOpenCloseInode(self, parent_path_spec):
Args:
parent_path_spec (PathSpec): parent path specification.
"""
path_spec = tsk_path_spec.TSKPathSpec(
inode=self._INODE_PASSWORDS_TXT, parent=parent_path_spec)
file_object = tsk_file_io.TSKFile(self._resolver_context)
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.PREFERRED_EXT_BACK_END, inode=self._INODE_PASSWORDS_TXT,
parent=parent_path_spec)
file_object = resolver.Resolver.OpenFileObject(
path_spec, resolver_context=self._resolver_context)

file_object.open(path_spec=path_spec)
self.assertEqual(file_object.get_size(), 116)
Expand All @@ -47,9 +52,11 @@ def _TestOpenCloseLocation(self, parent_path_spec):
Args:
parent_path_spec (PathSpec): parent path specification.
"""
path_spec = tsk_path_spec.TSKPathSpec(
location='/passwords.txt', parent=parent_path_spec)
file_object = tsk_file_io.TSKFile(self._resolver_context)
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.PREFERRED_EXT_BACK_END, location='/passwords.txt',
parent=parent_path_spec)
file_object = resolver.Resolver.OpenFileObject(
path_spec, resolver_context=self._resolver_context)

file_object.open(path_spec=path_spec)
self.assertEqual(file_object.get_size(), 116)
Expand All @@ -61,10 +68,11 @@ def _TestSeek(self, parent_path_spec):
Args:
parent_path_spec (PathSpec): parent path specification.
"""
path_spec = tsk_path_spec.TSKPathSpec(
inode=self._INODE_ANOTHER_FILE, location='/a_directory/another_file',
parent=parent_path_spec)
file_object = tsk_file_io.TSKFile(self._resolver_context)
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.PREFERRED_EXT_BACK_END, inode=self._INODE_ANOTHER_FILE,
location='/a_directory/another_file', parent=parent_path_spec)
file_object = resolver.Resolver.OpenFileObject(
path_spec, resolver_context=self._resolver_context)

file_object.open(path_spec=path_spec)
self.assertEqual(file_object.get_size(), 22)
Expand Down Expand Up @@ -105,10 +113,11 @@ def _TestRead(self, parent_path_spec):
Args:
parent_path_spec (PathSpec): parent path specification.
"""
path_spec = tsk_path_spec.TSKPathSpec(
inode=self._INODE_PASSWORDS_TXT, location='/passwords.txt',
parent=parent_path_spec)
file_object = tsk_file_io.TSKFile(self._resolver_context)
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.PREFERRED_EXT_BACK_END, inode=self._INODE_PASSWORDS_TXT,
location='/passwords.txt', parent=parent_path_spec)
file_object = resolver.Resolver.OpenFileObject(
path_spec, resolver_context=self._resolver_context)

file_object.open(path_spec=path_spec)
read_buffer = file_object.read()
Expand Down

0 comments on commit 6a2dec5

Please sign in to comment.