def test_sorting_nodes_2(): dict_depth = 3 tree = Tree(get_random_dict(dict_depth)) request = ' '.join([random.choice(tree.root.children).name, random.choice(tree.root.children).name] + \ list(''.join(random.choices(string.ascii_lowercase, k=10)) for _ in range(10))) nodes = tree._sorting_children(tree.root, request)
def test_sorting_nodes(): dict_depth = 3 tree = Tree(get_random_dict(dict_depth)) for child in tree.root.children: child.name = f"data{''.join(tuple(random.choices(string.ascii_lowercase, k=10)))}" nodes = tree._sorting_children(tree.root, "data") assert len(nodes) == len(tree.root.children) for node, weight in nodes: assert weight.distance == 10 assert weight.word == "data"