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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for the Virtual File System (VFS) path specification interface."""
from __future__ import unicode_literals
import unittest
from dfvfs.path import path_spec
from tests.path import test_lib
class TestPathSpec(path_spec.PathSpec):
"""Path specification for testing."""
TYPE_INDICATOR = 'test'
def __init__(self, parent=None, **kwargs):
"""Initializes a path specification.
Args:
parent (Optional[PathSpec]): parent path specification.
"""
super(TestPathSpec, self).__init__(parent=parent, **kwargs)
self.attribute = 'MyAttribute'
class PathSpecTest(test_lib.PathSpecTestCase):
"""Tests for the VFS path specification interface."""
# pylint: disable=protected-access
def testInitialize(self):
"""Tests the __init__ function."""
with self.assertRaises(ValueError):
path_spec.PathSpec()
# TODO: add tests for __eq__
# TODO: add tests for __hash__
def testGetComparable(self):
"""Tests the _GetComparable function."""
test_path_spec = TestPathSpec()
test_comparable = test_path_spec._GetComparable()
self.assertEqual(test_comparable, 'type: test\n')
def testComparable(self):
"""Tests the comparable property."""
test_path_spec = TestPathSpec()
self.assertEqual(test_path_spec.comparable, 'type: test\n')
def testTypeIndicator(self):
"""Tests the type_indicator property."""
test_path_spec = TestPathSpec()
self.assertEqual(test_path_spec.type_indicator, 'test')
def testCopyToDict(self):
"""Tests the CopyToDict function."""
test_path_spec = TestPathSpec()
test_dict = test_path_spec.CopyToDict()
self.assertEqual(test_dict, {'attribute': 'MyAttribute'})
def testHasParent(self):
"""Tests the HasParent function."""
test_path_spec = TestPathSpec()
self.assertFalse(test_path_spec.HasParent())
def testIsFileSystem(self):
"""Tests the IsFileSystem function."""
test_path_spec = TestPathSpec()
self.assertFalse(test_path_spec.IsFileSystem())
def testIsSystemLevel(self):
"""Tests the IsSystemLevel function."""
test_path_spec = TestPathSpec()
self.assertFalse(test_path_spec.IsSystemLevel())
def testIsVolumeSystem(self):
"""Tests the IsVolumeSystem function."""
test_path_spec = TestPathSpec()
self.assertFalse(test_path_spec.IsVolumeSystem())
def testIsVolumeSystemRoot(self):
"""Tests the IsVolumeSystemRoot function."""
test_path_spec = TestPathSpec()
self.assertFalse(test_path_spec.IsVolumeSystemRoot())
if __name__ == '__main__':
unittest.main()
|