🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: +test
莘权 马255c56ca2658
diff --git a/tests/metagpt/actions/test_write_teaching_plan.py b/tests/metagpt/actions/test_write_teaching_plan.pynew file mode 100644index 000000000..b47d6ab56--- /dev/null+++ b/tests/metagpt/actions/test_write_teaching_plan.py@@ -0,0 +1,57 @@+import asyncio+from typing import Optional+from pydantic import BaseModel+from langchain.llms.base import LLM++from metagpt.actions.write_teaching_plan import WriteTeachingPlanPart+from metagpt.schema import Message+++class MockWriteTeachingPlanPart(WriteTeachingPlanPart):+ def __init__(self, name: str = '', context=None, llm: LLM = None, topic="", language="Chinese"):+ super().__init__(name, context, llm, topic, language)++ async def _aask(self, prompt: str, system_msgs: Optional[list[str]] = None) -> str:+ return f"{WriteTeachingPlanPart.DATA_BEGIN_TAG}\nprompt\n{WriteTeachingPlanPart.DATA_END_TAG}"+++async def mock_write_teaching_plan_part():+ class Inputs(BaseModel):+ input: str+ name: str+ topic: str+ language: str++ inputs = [+ {+ "input": "AABBCC",+ "name": "A",+ "topic": "B",+ "language": "C"+ },+ {+ "input": "DDEEFFF",+ "name": "A1",+ "topic": "B1",+ "language": "C1"+ }+ ]++ for i in inputs:+ seed = Inputs(**i)+ act = MockWriteTeachingPlanPart(name=seed.name, topic=seed.topic, language=seed.language)+ await act.run([Message(content="")])+ assert act.topic == seed.topic+ assert str(act) == seed.topic+ assert act.name == seed.name+ assert act.rsp == "prompt"+++def test_suite():+ loop = asyncio.get_event_loop()+ task = loop.create_task(mock_write_teaching_plan_part())+ loop.run_until_complete(task)+++if __name__ == '__main__':+ test_suite()diff --git a/tests/metagpt/roles/test_teacher.py b/tests/metagpt/roles/test_teacher.pyindex 10789f868..3af053338 100644--- a/tests/metagpt/roles/test_teacher.py+++ b/tests/metagpt/roles/test_teacher.py@@ -93,3 +93,4 @@ def test_new_file_name():if __name__ == '__main__':test_init()+ test_new_file_name()