🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fixbug: unit test
莘权 马fd11f46587c9
diff --git a/tests/metagpt/actions/test_skill_action.py b/tests/metagpt/actions/test_skill_action.pyindex 0e0d5d5aa..69cd8129d 100644--- a/tests/metagpt/actions/test_skill_action.py+++ b/tests/metagpt/actions/test_skill_action.py@@ -47,7 +47,10 @@ class TestSkillAction:assert args.get("size_type") == "512x512"@pytest.mark.asyncio- async def test_parser_action(self):+ async def test_parser_action(self, mocker):+ # mock+ mocker.patch("metagpt.learn.text_to_image", return_value="https://mock.com/xxx")+parser_action = ArgumentsParingAction(skill=self.skill, ask="Draw an apple")rsp = await parser_action.run()assert rsp@@ -80,7 +83,8 @@ class TestSkillAction:@pytest.mark.asyncioasync def test_skill_action_error(self):action = SkillAction(skill=self.skill, args={})- await action.run()+ rsp = await action.run()+ assert "Error" in rsp.contentif __name__ == "__main__":diff --git a/tests/metagpt/learn/test_text_to_image.py b/tests/metagpt/learn/test_text_to_image.pyindex 760b9d09c..1485df5c6 100644--- a/tests/metagpt/learn/test_text_to_image.py+++ b/tests/metagpt/learn/test_text_to_image.py@@ -12,10 +12,18 @@ import pytestfrom metagpt.config import CONFIGfrom metagpt.learn.text_to_image import text_to_image+from metagpt.tools.metagpt_text_to_image import MetaGPTText2Image+from metagpt.tools.openai_text_to_image import OpenAIText2Image+from metagpt.utils.s3 import S3@pytest.mark.asyncio-async def test_metagpt_llm():+async def test_text_to_image(mocker):+ # mock+ mocker.patch.object(MetaGPTText2Image, "text_2_image", return_value=b"mock MetaGPTText2Image")+ mocker.patch.object(OpenAIText2Image, "text_2_image", return_value=b"mock OpenAIText2Image")+ mocker.patch.object(S3, "cache", return_value="http://mock/s3")+# Prerequisitesassert CONFIG.METAGPT_TEXT_TO_IMAGE_MODEL_URLassert CONFIG.OPENAI_API_KEY