mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
feat: +unit test
This commit is contained in:
parent
f3f19811a0
commit
cfedba061a
2 changed files with 17 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -166,3 +166,4 @@ output
|
|||
tmp.png
|
||||
.dependencies.json
|
||||
tests/metagpt/utils/file_repo_git
|
||||
*.tmp
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
"""
|
||||
@Time : 2023/4/30 21:44
|
||||
@Author : alexanderwu
|
||||
@File : test_ut_generator.py
|
||||
@File : test_ut_writer.py
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.const import API_QUESTIONS_PATH, SWAGGER_PATH, UT_PY_PATH
|
||||
from metagpt.tools.ut_writer import YFT_PROMPT_PREFIX, UTGenerator
|
||||
|
|
@ -12,7 +15,10 @@ from metagpt.tools.ut_writer import YFT_PROMPT_PREFIX, UTGenerator
|
|||
|
||||
class TestUTWriter:
|
||||
def test_api_to_ut_sample(self):
|
||||
# Prerequisites
|
||||
swagger_file = SWAGGER_PATH / "yft_swaggerApi.json"
|
||||
assert swagger_file.exists()
|
||||
|
||||
tags = ["测试"] # "智能合同导入", "律师审查", "ai合同审查", "草拟合同&律师在线审查", "合同审批", "履约管理", "签约公司"]
|
||||
# 这里在文件中手动加入了两个测试标签的API
|
||||
|
||||
|
|
@ -25,3 +31,12 @@ class TestUTWriter:
|
|||
ret = utg.generate_ut(include_tags=tags)
|
||||
# 后续加入对文件生成内容与数量的检验
|
||||
assert ret
|
||||
|
||||
pathname = Path(__file__).with_suffix(".tmp")
|
||||
utg.ask_gpt_and_save(question="question", tag="tag", fname=str(pathname))
|
||||
assert pathname.exists()
|
||||
pathname.unlink(missing_ok=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue