Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

add test

geekan25c42890b8bc
diff --git a/tests/metagpt/actions/test_action_node.py b/tests/metagpt/actions/test_action_node.py
index 92d8a1bbc..ebc428d75 100644
--- a/tests/metagpt/actions/test_action_node.py
+++ b/tests/metagpt/actions/test_action_node.py
@@ -76,6 +76,7 @@ async def test_action_node_one_layer():
assert "key-a" in markdown_template
assert node_dict["key-a"] == "instruction-b"
+ assert "key-a" in repr(node)
@pytest.mark.asyncio
@@ -116,11 +117,28 @@ WRITE_TASKS_OUTPUT_MAPPING = {
"Anything UNCLEAR": (str, ...),
}
+WRITE_TASKS_OUTPUT_MAPPING_MISSING = {
+ "Required Python third-party packages": (str, ...),
+}
+
def test_create_model_class():
test_class = ActionNode.create_model_class("test_class", WRITE_TASKS_OUTPUT_MAPPING)
assert test_class.__name__ == "test_class"
+ output = test_class(**t_dict)
+ print(output.schema())
+ assert output.schema()["title"] == "test_class"
+ assert output.schema()["type"] == "object"
+ assert output.schema()["properties"]["Full API spec"]
+
+
+def test_create_model_class_missing():
+ test_class = ActionNode.create_model_class("test_class", WRITE_TASKS_OUTPUT_MAPPING_MISSING)
+ assert test_class.__name__ == "test_class"
+
+ _ = test_class(**t_dict) # 这里应该要挂掉
+
def test_create_model_class_with_mapping():
t = ActionNode.create_model_class("test_class_1", WRITE_TASKS_OUTPUT_MAPPING)
diff --git a/tests/metagpt/test_startup.py b/tests/metagpt/test_startup.py
index c8d4d5d29..134dba04f 100644
--- a/tests/metagpt/test_startup.py
+++ b/tests/metagpt/test_startup.py
@@ -9,23 +9,24 @@ import pytest
from typer.testing import CliRunner
from metagpt.logs import logger
+from metagpt.startup import app
from metagpt.team import Team
runner = CliRunner()
@pytest.mark.asyncio
-async def test_team():
+async def test_empty_team():
# FIXME: we're now using "metagpt" cli, so the entrance should be replaced instead.
company = Team()
- company.run_project("做一个基础搜索引擎,可以支持知识库")
- history = await company.run(n_round=5)
+ history = await company.run(idea="Build a simple search system. I will upload my files later.")
logger.info(history)
-# def test_startup():
-# args = ["Make a 2048 game"]
-# result = runner.invoke(app, args)
+def test_startup():
+ args = ["Make a 2048 game"]
+ result = runner.invoke(app, args)
+ logger.info(result)
if __name__ == "__main__":