main to dev.

This commit is contained in:
geekan 2024-01-08 16:29:00 +08:00
commit 4e9a794629
6 changed files with 61 additions and 6 deletions

View file

@ -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.asyncio
async def test_skill_action_error(self):
action = SkillAction(skill=self.skill, args={})
await action.run()
rsp = await action.run()
assert "Error" in rsp.content
if __name__ == "__main__":

View file

@ -12,10 +12,18 @@ import pytest
from metagpt.config2 import Config
from 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_text_to_image():
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")
config = Config()
assert config.METAGPT_TEXT_TO_IMAGE_MODEL_URL

View file

@ -284,4 +284,6 @@ class MockMessages:
prd = Message(role="Product Manager", content=PRD, cause_by=WritePRD)
system_design = Message(role="Architect", content=SYSTEM_DESIGN, cause_by=WriteDesign)
tasks = Message(role="Project Manager", content=TASKS, cause_by=WriteTasks)
json_tasks = Message(role="Project Manager", content=json.dumps(JSON_TASKS), cause_by=WriteTasks)
json_tasks = Message(
role="Project Manager", content=json.dumps(JSON_TASKS, ensure_ascii=False), cause_by=WriteTasks
)

View file

@ -29,6 +29,7 @@ def search_engine_server():
meilisearch_process.wait()
@pytest.mark.skip
def test_meilisearch(search_engine_server):
# Prerequisites
# https://www.meilisearch.com/docs/learn/getting_started/installation