def test_analyze_tree_1(): tree_1 = alias(child=repeat_until(child=action(hello), condition=success_until_zero), name="btree_1") a_tree_1 = analyze(tree_1) printed_tree = """ --> btree_1:\n --(child)--> repeat_until:\n --(condition)--> success_until_zero:\n --(child)--> action:\n target: hello\n""" # noqa: E501, B950 assert stringify_analyze(a_tree_1) == printed_tree
def test_analyze_sequence(): a_tree = analyze( alias( child=repeat_until( child=sequence(children=[action(hello), action(hello), action(hello)]), condition=success_until_zero ), name="btree_1", ) ) print_test = """ --> btree_1:\n --(child)--> repeat_until:\n --(condition)--> success_until_zero:\n --(child)--> sequence:\n succes_threshold: 3\n --(children)--> action:\n target: hello\n --(children)--> action:\n target: hello\n --(children)--> action:\n target: hello\n""" # noqa: E501, B950 assert stringify_analyze(a_tree) == print_test
async def test_alias_not_override(): a_rooted = alias(child=a_func, name='a_func') b_rooted = alias(child=a_func, name='b_func') assert a_rooted.__node_metadata.name == 'a_func' assert b_rooted.__node_metadata.name == 'b_func'
async def test_alias_name(): rooted = alias(child=a_func, name='a_func') assert rooted.__node_metadata.name == 'a_func' assert await rooted() == 'a'
def test_node_str(): node = analyze(alias(child=action(target=hello), name='a test')) printed_tree = """ --> a test:\n --(child)--> action:\n target: hello\n""" assert str(node) == printed_tree
def test_root_name(kernel): rooted = alias(child=a_func, name='a_func') assert rooted.__node_metadata.name == 'a_func' assert kernel.run(rooted) == 'a'