This commit is contained in:
geekan 2024-01-10 22:02:44 +08:00
parent 8af1488613
commit 4de8fa3682
15 changed files with 33 additions and 24 deletions

View file

@ -14,7 +14,6 @@ from metagpt.const import GRAPH_REPO_FILE_REPO
from metagpt.context import CONTEXT
from metagpt.llm import LLM
from metagpt.utils.common import aread
from metagpt.utils.file_repository import FileRepository
from metagpt.utils.git_repository import ChangeType
@ -23,7 +22,8 @@ async def test_rebuild():
# Mock
data = await aread(filename=Path(__file__).parent / "../../data/graph_db/networkx.json")
graph_db_filename = Path(CONTEXT.git_repo.workdir.name).with_suffix(".json")
await FileRepository.save_file(
repo = CONTEXT.file_repo
await repo.save_file(
filename=str(graph_db_filename),
relative_path=GRAPH_REPO_FILE_REPO,
content=data,

View file

@ -62,7 +62,7 @@ async def test_react():
"goal": "Test",
"constraints": "constraints",
"desc": "desc",
"subscription": "start",
"address": "start",
}
]
@ -93,8 +93,8 @@ async def test_react():
await env.run()
assert role.is_idle
tag = uuid.uuid4().hex
role.subscribe({tag})
assert env.get_subscription(role) == {tag}
role.set_addresses({tag})
assert env.get_addresses(role) == {tag}
@pytest.mark.asyncio
@ -131,7 +131,7 @@ async def test_recover():
role.recovered = True
role.latest_observed_msg = Message(content="recover_test")
role.rc.state = 0
assert role.todo == any_to_name(MockAction)
assert role.first_action == any_to_name(MockAction)
rsp = await role.run()
assert rsp.cause_by == any_to_str(MockAction)

View file

@ -102,7 +102,7 @@ def test_message_serdeser():
new_message = Message.model_validate(message_dict)
assert new_message.content == message.content
assert new_message.instruct_content.model_dump() == message.instruct_content.model_dump()
assert new_message.instruct_content != message.instruct_content # TODO
assert new_message.instruct_content == message.instruct_content # TODO
assert new_message.cause_by == message.cause_by
assert new_message.instruct_content.field3 == out_data["field3"]

View file

@ -22,7 +22,7 @@ async def async_mock_from_url(*args, **kwargs):
@pytest.mark.asyncio
@mock.patch("aioredis.from_url", return_value=async_mock_from_url())
async def test_redis():
async def test_redis(i):
redis = Config.default().redis
conn = Redis(redis)