1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the path specification factory."""
import unittest
from dfvfs.lib import definitions
from dfvfs.path import factory
from tests.path import test_lib
class FactoryTest(unittest.TestCase):
"""Class to test the path specification factory object."""
def testPathSpecRegistration(self):
"""Tests the DeregisterPathSpec and DeregisterPathSpec functions."""
# pylint: disable=protected-access
number_of_path_spec_types = len(factory.Factory._path_spec_types)
factory.Factory.RegisterPathSpec(test_lib.TestPathSpec)
self.assertEqual(
len(factory.Factory._path_spec_types),
number_of_path_spec_types + 1)
with self.assertRaises(KeyError):
factory.Factory.RegisterPathSpec(test_lib.TestPathSpec)
factory.Factory.DeregisterPathSpec(test_lib.TestPathSpec)
self.assertEqual(
len(factory.Factory._path_spec_types), number_of_path_spec_types)
def testNewPathSpec(self):
"""Tests the NewPathSpec function."""
test_path_spec = factory.Factory.NewPathSpec(
definitions.TYPE_INDICATOR_OS, location=u'/test')
self.assertIsNotNone(test_path_spec)
def testIsSystemLevelTypeIndicator(self):
"""Tests the IsSystemLevelTypeIndicator function."""
result = factory.Factory.IsSystemLevelTypeIndicator(
definitions.TYPE_INDICATOR_OS)
self.assertTrue(result)
result = factory.Factory.IsSystemLevelTypeIndicator(
definitions.TYPE_INDICATOR_TSK)
self.assertFalse(result)
if __name__ == '__main__':
unittest.main()
|