From c7f47e80add05eb7bb4ea8c303ab7641caec92e7 Mon Sep 17 00:00:00 2001 From: geekan Date: Sat, 23 Dec 2023 19:35:07 +0800 Subject: [PATCH] add test --- metagpt/actions/action.py | 2 +- tests/metagpt/actions/test_action_node.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/metagpt/actions/action.py b/metagpt/actions/action.py index 24237c6f1..c8c901eb0 100644 --- a/metagpt/actions/action.py +++ b/metagpt/actions/action.py @@ -59,7 +59,7 @@ def __init_subclass__(cls, **kwargs: Any) -> None: action_subclass_registry[cls.__name__] = cls def dict(self, *args, **kwargs) -> "DictStrAny": - obj_dict = super(Action, self).dict(*args, **kwargs) + obj_dict = super().dict(*args, **kwargs) if "llm" in obj_dict: obj_dict.pop("llm") return obj_dict diff --git a/tests/metagpt/actions/test_action_node.py b/tests/metagpt/actions/test_action_node.py index 24b48f2f6..5bafe2bf2 100644 --- a/tests/metagpt/actions/test_action_node.py +++ b/tests/metagpt/actions/test_action_node.py @@ -53,7 +53,7 @@ async def test_debate_one_role(): @pytest.mark.asyncio -async def test_action_node(): +async def test_action_node_one_layer(): node = ActionNode(key="key-a", expected_type=str, instruction="instruction-b", example="example-c") raw_template = node.compile(context="123", schema="raw", mode="auto") @@ -74,3 +74,15 @@ async def test_action_node(): assert "key-a" in markdown_template assert node_dict["key-a"] == "instruction-b" + + +@pytest.mark.asyncio +async def test_action_node_two_layer(): + node_a = ActionNode(key="key-a", expected_type=str, instruction="i-a", example="e-a") + node_b = ActionNode(key="key-b", expected_type=str, instruction="i-b", example="e-b") + + root = ActionNode.from_children(key="", nodes=[node_a, node_b]) + assert "key-a" in root.children + assert node_b in root.children.values() + json_template = root.compile(context="123", schema="json", mode="auto") + assert "i-a" in json_template