Merge pull request #16 from Stitch-z/feature-tutorial-assistant

Update: improve the unit testing of tutorial assistants and OCR assis…
This commit is contained in:
Stitch-z 2023-12-26 16:05:21 +08:00 committed by GitHub
commit 08fb68efc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,19 +5,27 @@
@Author : Stitch-z
@File : test_tutorial_assistant.py
"""
import shutil
import aiofiles
import pytest
from metagpt.const import TUTORIAL_PATH
from metagpt.roles.tutorial_assistant import TutorialAssistant
@pytest.mark.asyncio
@pytest.mark.parametrize(("language", "topic"), [("Chinese", "Write a tutorial about pip")])
async def test_tutorial_assistant(language: str, topic: str):
shutil.rmtree(path=TUTORIAL_PATH, ignore_errors=True)
role = TutorialAssistant(language=language)
msg = await role.run(topic)
assert TUTORIAL_PATH.exists()
filename = msg.content
async with aiofiles.open(filename, mode="r", encoding="utf-8") as reader:
content = await reader.read()
assert content
assert "pip" in content
if __name__ == "__main__":
pytest.main([__file__, "-s"])