Example #1
0
    def test_is_file(self):
        node = Node('any', NodeKind.FILE)
        self.assertTrue(node.is_file())

        node = FileNode('any')
        self.assertTrue(node.is_file())
        self.assertRaises(AttributeError, getattr, node, 'nodes')
Example #2
0
    def test_is_file(self):
        node = Node('any', NodeKind.FILE)
        self.assertTrue(node.is_file())

        node = FileNode('any')
        self.assertTrue(node.is_file())
        self.assertRaises(AttributeError, getattr, node, 'nodes')
Example #3
0
    def test_is_file(self):
        node = Node('any', NodeKind.FILE)
        assert node.is_file()

        node = FileNode('any')
        assert node.is_file()
        with pytest.raises(AttributeError):
            node.nodes
Example #4
0
    def test_is_dir(self):
        node = Node('any_dir', NodeKind.DIR)
        self.assertTrue(node.is_dir())

        node = DirNode('any_dir')

        self.assertTrue(node.is_dir())
        self.assertRaises(NodeError, getattr, node, 'content')
Example #5
0
    def test_is_dir(self):
        node = Node('any_dir', NodeKind.DIR)
        self.assertTrue(node.is_dir())

        node = DirNode('any_dir')

        self.assertTrue(node.is_dir())
        self.assertRaises(NodeError, getattr, node, 'content')
Example #6
0
    def test_is_dir(self):
        node = Node('any_dir', NodeKind.DIR)
        assert node.is_dir()

        node = DirNode('any_dir')

        assert node.is_dir()
        with pytest.raises(NodeError):
            node.content
Example #7
0
 def test_parent_path_new(self, node_path, expected_parent_path):
     """
     Tests if node's parent path are properly computed.
     """
     node = Node(node_path, NodeKind.DIR)
     parent_path = node.get_parent_path()
     assert (parent_path.endswith('/')
             or node.is_root() and parent_path == '')
     assert parent_path == expected_parent_path
Example #8
0
 def _test_parent_path(self, node_path, expected_parent_path):
     """
     Tests if node's parent path are properly computed.
     """
     node = Node(node_path, NodeKind.DIR)
     parent_path = node.get_parent_path()
     self.assertTrue(parent_path.endswith('/') or \
         node.is_root() and parent_path == '')
     self.assertEqual(parent_path, expected_parent_path,
         "Node's path is %r and parent path is %r but should be %r"
         % (node.path, parent_path, expected_parent_path))
Example #9
0
 def _test_parent_path(self, node_path, expected_parent_path):
     """
     Tests if node's parent path are properly computed.
     """
     node = Node(node_path, NodeKind.DIR)
     parent_path = node.get_parent_path()
     self.assertTrue(parent_path.endswith('/') or \
         node.is_root() and parent_path == '')
     self.assertEqual(parent_path, expected_parent_path,
         "Node's path is %r and parent path is %r but should be %r"
         % (node.path, parent_path, expected_parent_path))
Example #10
0
    def test_name(self):
        node = Node('', NodeKind.DIR)
        self.assertEqual(node.name, '')

        node = Node('path', NodeKind.FILE)
        self.assertEqual(node.name, 'path')

        node = Node('path/', NodeKind.DIR)
        self.assertEqual(node.name, 'path')

        node = Node('some/path', NodeKind.FILE)
        self.assertEqual(node.name, 'path')

        node = Node('some/path/', NodeKind.DIR)
        self.assertEqual(node.name, 'path')
Example #11
0
 def test_kind_setter(self):
     node = Node('', NodeKind.DIR)
     with pytest.raises(NodeError):
         node.kind = NodeKind.FILE
Example #12
0
 def test_root_node_cannot_be_file(self):
     with pytest.raises(NodeError):
         Node('', NodeKind.FILE)
Example #13
0
 def test_name_root(self):
     node = Node('', NodeKind.DIR)
     assert node.name == ''
Example #14
0
 def test_name(self, path, kind):
     node = Node(path, kind)
     assert node.name == 'path'
Example #15
0
 def test_init_wrong_paths(self, path, kind):
     """
     Cannot innitialize Node objects with path with slash at the beginning.
     """
     with pytest.raises(NodeError):
         Node(path, kind)
Example #16
0
 def test_kind_setter(self):
     node = Node('', NodeKind.DIR)
     self.assertRaises(NodeError, setattr, node, 'kind', NodeKind.FILE)