Ejemplo n.º 1
0
 def create_label_tree(self, name, external_id=None):
     '''Create a new LabelTree
     
     Args:
         name (str): Name of the tree / name of the root leaf.
         external_id (str): An external id for the root leaf.
     
     Returns:
         :class:`lost.logic.label.LabelTree`:
             The created LabelTree.
     '''
     tree = LabelTree(self._dbm)
     tree.create_root(name, external_id=external_id)
     return tree
Ejemplo n.º 2
0
 def test_create_delete_tree(self):
     dbm = DBMan(config.LOSTConfig())
     tree = LabelTree(dbm)
     root_leaf = tree.create_root(ROOT_NAME, external_id=ROOT_EXTERNAL_ID)
     assert root_leaf.name == ROOT_NAME
     assert root_leaf.external_id == ROOT_EXTERNAL_ID
     assert tree.tree[root_leaf.idx] == root_leaf
     tree.delete_tree()
Ejemplo n.º 3
0
def tree_plus_childs():
    dbm = DBMan(config.LOSTConfig())
    tree = LabelTree(dbm)
    root_leaf = tree.create_root(ROOT_NAME, external_id=ROOT_EXTERNAL_ID)
    horse = tree.create_child(tree.root.idx,
                              CHILD_HORSE_NAME,
                              external_id=CHILD_HORSE_EXTERNAL_ID)
    cow = tree.create_child(tree.root.idx,
                            CHILD_COW_NAME,
                            external_id=CHILD_COW_EXTERNAL_ID)
    yield tree  # type: lost.logic.label.LabelTree
    tree.delete_tree()
Ejemplo n.º 4
0
def tree():
    dbm = DBMan(config.LOSTConfig())
    tree = LabelTree(dbm)
    root_leaf = tree.create_root(ROOT_NAME, external_id=ROOT_EXTERNAL_ID)
    yield tree
    tree.delete_tree()