🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
update test file of ActionNode
mannaandpoemfe64b23a0ec2
diff --git a/tests/metagpt/actions/test_design_api_an.py b/tests/metagpt/actions/test_design_api_an.pyindex 2aa123224..39de2a595 100644--- a/tests/metagpt/actions/test_design_api_an.py+++ b/tests/metagpt/actions/test_design_api_an.py@@ -6,6 +6,7 @@@File : test_design_api_an.py"""import pytest+from openai._models import BaseModelfrom metagpt.actions.action_node import ActionNode, dict_to_markdownfrom metagpt.actions.design_api import NEW_REQ_TEMPLATE@@ -23,17 +24,23 @@ def llm():return LLM()+def mock_refined_design_json():+ return REFINED_DESIGN_JSON++@pytest.mark.asyncioasync def test_write_design_an(mocker):root = ActionNode.from_children("RefinedDesignAPI", [ActionNode(key="", expected_type=str, instruction="", example="")])- root.instruct_content = REFINED_DESIGN_JSON-+ root.instruct_content = BaseModel()+ root.instruct_content.model_dump = mock_refined_design_jsonmocker.patch("metagpt.actions.design_api_an.REFINED_DESIGN_NODES.fill", return_value=root)+prompt = NEW_REQ_TEMPLATE.format(old_design=DESIGN_SAMPLE, context=dict_to_markdown(REFINED_PRD_JSON))node = await REFINED_DESIGN_NODES.fill(prompt, llm)- assert "Refined Implementation Approach" in node.instruct_content- assert "Refined File list" in node.instruct_content- assert "Refined Data structures and interfaces" in node.instruct_content- assert "Refined Program call flow" in node.instruct_content++ assert "Refined Implementation Approach" in node.instruct_content.model_dump()+ assert "Refined File list" in node.instruct_content.model_dump()+ assert "Refined Data structures and interfaces" in node.instruct_content.model_dump()+ assert "Refined Program call flow" in node.instruct_content.model_dump()diff --git a/tests/metagpt/actions/test_project_management_an.py b/tests/metagpt/actions/test_project_management_an.pyindex 0540ed6e1..50dc47067 100644--- a/tests/metagpt/actions/test_project_management_an.py+++ b/tests/metagpt/actions/test_project_management_an.py@@ -6,6 +6,7 @@@File : test_project_management_an.py"""import pytest+from openai._models import BaseModelfrom metagpt.actions.action_node import ActionNode, dict_to_markdownfrom metagpt.actions.project_management import NEW_REQ_TEMPLATE@@ -23,18 +24,22 @@ def llm():return LLM()+def mock_refined_tasks_json():+ return REFINED_TASKS_JSON++@pytest.mark.asyncioasync def test_project_management_an(mocker):root = ActionNode.from_children("RefinedProjectManagement", [ActionNode(key="", expected_type=str, instruction="", example="")])- root.instruct_content = REFINED_TASKS_JSON-+ root.instruct_content = BaseModel()+ root.instruct_content.model_dump = mock_refined_tasks_jsonmocker.patch("metagpt.actions.project_management_an.REFINED_PM_NODES.fill", return_value=root)prompt = NEW_REQ_TEMPLATE.format(old_tasks=TASKS_SAMPLE, context=dict_to_markdown(REFINED_DESIGN_JSON))node = await REFINED_PM_NODES.fill(prompt, llm)- assert node.instruct_content- assert "Refined Logic Analysis" in node.instruct_content- assert "Refined Task list" in node.instruct_content- assert "Refined Shared Knowledge" in node.instruct_content++ assert "Refined Logic Analysis" in node.instruct_content.model_dump()+ assert "Refined Task list" in node.instruct_content.model_dump()+ assert "Refined Shared Knowledge" in node.instruct_content.model_dump()diff --git a/tests/metagpt/actions/test_write_code_guideline_an.py b/tests/metagpt/actions/test_write_code_guideline_an.pyindex 998605c4b..5a4e19d57 100644--- a/tests/metagpt/actions/test_write_code_guideline_an.py+++ b/tests/metagpt/actions/test_write_code_guideline_an.py@@ -6,6 +6,7 @@@File : test_write_code_guideline_an.py"""import pytest+from openai._models import BaseModelfrom metagpt.actions.action_node import ActionNodefrom metagpt.actions.write_code import WriteCode@@ -28,12 +29,17 @@ from tests.data.incremental_dev_project.mock import ()+def mock_guidelines_and_incremental_change():+ return GUIDELINES_AND_INCREMENTAL_CHANGE_SAMPLE++@pytest.mark.asyncioasync def test_write_code_guideline_an(mocker):root = ActionNode.from_children("WriteCodeGuideline", [ActionNode(key="", expected_type=str, instruction="", example="")])- root.instruct_content = GUIDELINES_AND_INCREMENTAL_CHANGE_SAMPLE+ root.instruct_content = BaseModel()+ root.instruct_content.model_dump = mock_guidelines_and_incremental_changemocker.patch("metagpt.actions.write_code_guideline_an.WriteCodeGuideline.run", return_value=root)write_code_guideline = WriteCodeGuideline()@@ -45,7 +51,8 @@ async def test_write_code_guideline_an(mocker):code=OLD_CODE_SAMPLE,)node = await write_code_guideline.run(context=context)- assert "Guidelines and Incremental Change" in node.instruct_content++ assert "Guidelines and Incremental Change" in node.instruct_content.model_dump()@pytest.mark.asynciodiff --git a/tests/metagpt/actions/test_write_prd_an.py b/tests/metagpt/actions/test_write_prd_an.pyindex e7f288c68..1fdaa75c2 100644--- a/tests/metagpt/actions/test_write_prd_an.py+++ b/tests/metagpt/actions/test_write_prd_an.py@@ -6,6 +6,7 @@@File : test_write_prd_an.py"""import pytest+from openai._models import BaseModelfrom metagpt.actions.action_node import ActionNodefrom metagpt.actions.write_prd_an import REFINE_PRD_NODE, REFINE_PRD_TEMPLATE@@ -22,20 +23,26 @@ def llm():return LLM()+def mock_refined_prd_json():+ return REFINED_PRD_JSON++@pytest.mark.asyncioasync def test_write_prd_an(mocker):root = ActionNode.from_children("RefinePRD", [ActionNode(key="", expected_type=str, instruction="", example="")])- root.instruct_content = REFINED_PRD_JSON-+ root.instruct_content = BaseModel()+ root.instruct_content.model_dump = mock_refined_prd_jsonmocker.patch("metagpt.actions.write_prd_an.REFINE_PRD_NODE.fill", return_value=root)+prompt = REFINE_PRD_TEMPLATE.format(requirements=NEW_REQUIREMENT_SAMPLE,old_prd=PRD_SAMPLE,project_name="",)node = await REFINE_PRD_NODE.fill(prompt, llm)- assert "Refined Requirements" in node.instruct_content- assert "Refined Product Goals" in node.instruct_content- assert "Refined User Stories" in node.instruct_content- assert "Refined Requirement Analysis" in node.instruct_content- assert "Refined Requirement Pool" in node.instruct_content++ assert "Refined Requirements" in node.instruct_content.model_dump()+ assert "Refined Product Goals" in node.instruct_content.model_dump()+ assert "Refined User Stories" in node.instruct_content.model_dump()+ assert "Refined Requirement Analysis" in node.instruct_content.model_dump()+ assert "Refined Requirement Pool" in node.instruct_content.model_dump()