コード例 #1
0
ファイル: test_file_tree.py プロジェクト: tzxfl/FACT_core
    def test_node_creation(self):
        parent_node = FileTreeNode('123',
                                   virtual=False,
                                   name='parent',
                                   size=1,
                                   mime_type='somefile')
        child_node = FileTreeNode('456',
                                  root_uid='123',
                                  virtual=True,
                                  name='child')
        parent_node.add_child_node(child_node)

        assert parent_node.uid == '123'
        assert parent_node.root_uid is None
        assert child_node.root_uid == '123'
        assert not parent_node.virtual
        assert parent_node.size == 1
        assert parent_node.type == 'somefile'
        assert parent_node.has_children
        assert parent_node.get_list_of_child_nodes() == [child_node]
        assert parent_node.get_id() == ('parent', False)
        assert list(parent_node.children.keys()) == [child_node.get_id()]
        assert parent_node.get_names_of_children() == [child_node.name]
        assert not child_node.has_children
        assert child_node in parent_node
        assert 'Node ' in parent_node.__repr__()
        assert parent_node != child_node
        assert parent_node.print_tree() is None
コード例 #2
0
ファイル: test_file_tree.py プロジェクト: xuacker/FACT_core
    def test_node_creation(self):
        parent_node = FileTreeNode('123',
                                   virtual=False,
                                   name='parent',
                                   size=1,
                                   mime_type='somefile')
        child_node = FileTreeNode('456',
                                  root_uid='123',
                                  virtual=True,
                                  name='child')
        parent_node.add_child_node(child_node)

        self.assertEqual(parent_node.uid, '123')
        self.assertEqual(parent_node.root_uid, None)
        self.assertEqual(child_node.root_uid, '123')
        self.assertFalse(parent_node.virtual)
        self.assertEqual(parent_node.size, 1)
        self.assertEqual(parent_node.type, 'somefile')
        self.assertTrue(parent_node.has_children)
        self.assertEqual(parent_node.get_list_of_child_nodes(), [child_node])
        self.assertEqual(parent_node.get_id(), ('parent', False))
        self.assertEqual(list(parent_node.children.keys()),
                         [child_node.get_id()])
        self.assertEqual(parent_node.get_names_of_children(),
                         [child_node.name])
        self.assertFalse(child_node.has_children)
        self.assertTrue(child_node in parent_node)
        assert 'Node ' in parent_node.__repr__()
        self.assertNotEqual(parent_node, child_node)
        assert parent_node.print_tree() is None