mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-07-02 16:01:04 +02:00
add test document
This commit is contained in:
parent
66d3e8448d
commit
54201b1459
3 changed files with 55 additions and 24 deletions
|
|
@ -5,6 +5,8 @@
|
|||
@Author : alexanderwu
|
||||
@File : test_action.py
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from metagpt.actions import Action, ActionType, WritePRD, WriteTest
|
||||
|
||||
|
||||
|
|
@ -18,3 +20,22 @@ def test_action_type():
|
|||
assert ActionType.WRITE_TEST.value == WriteTest
|
||||
assert ActionType.WRITE_PRD.name == "WRITE_PRD"
|
||||
assert ActionType.WRITE_TEST.name == "WRITE_TEST"
|
||||
|
||||
|
||||
def test_simple_action():
|
||||
action = Action(name="AlexSay", instruction="Express your opinion with emotion and don't repeat it")
|
||||
assert action.name == "AlexSay"
|
||||
assert action.node.instruction == "Express your opinion with emotion and don't repeat it"
|
||||
|
||||
|
||||
def test_empty_action():
|
||||
action = Action()
|
||||
assert action.name == "Action"
|
||||
assert not action.node
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_empty_action_exception():
|
||||
action = Action()
|
||||
with pytest.raises(NotImplementedError):
|
||||
await action.run()
|
||||
|
|
|
|||
33
tests/metagpt/test_document.py
Normal file
33
tests/metagpt/test_document.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2024/1/2 21:00
|
||||
@Author : alexanderwu
|
||||
@File : test_document.py
|
||||
"""
|
||||
from metagpt.config import CONFIG
|
||||
from metagpt.document import Repo
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
||||
def set_existing_repo(path):
|
||||
repo1 = Repo.from_path(path)
|
||||
repo1.set("doc/wtf_file.md", "wtf content")
|
||||
repo1.set("code/wtf_file.py", "def hello():\n print('hello')")
|
||||
logger.info(repo1) # check doc
|
||||
|
||||
|
||||
def load_existing_repo(path):
|
||||
repo = Repo.from_path(path)
|
||||
logger.info(repo)
|
||||
logger.info(repo.eda())
|
||||
|
||||
assert repo
|
||||
assert repo.get("doc/wtf_file.md").content == "wtf content"
|
||||
assert repo.get("code/wtf_file.py").content == "def hello():\n print('hello')"
|
||||
|
||||
|
||||
def test_repo_set_load():
|
||||
repo_path = CONFIG.workspace_path / "test_repo"
|
||||
set_existing_repo(repo_path)
|
||||
load_existing_repo(repo_path)
|
||||
Loading…
Add table
Add a link
Reference in a new issue