update ut

This commit is contained in:
better629 2024-03-28 18:23:43 +08:00
parent 1c8995211b
commit d80f65b538
11 changed files with 47 additions and 60 deletions

File diff suppressed because one or more lines are too long

View file

@ -15,7 +15,7 @@ from metagpt.environment.stanford_town.stanford_town_ext_env import StanfordTown
maze_asset_path = (
Path(__file__)
.absolute()
.parent.joinpath("..", "..", "..", "..", "examples/stanford_town/static_dirs/assets/the_ville")
.parent.joinpath("..", "..", "..", "..", "metagpt/ext/stanford_town/static_dirs/assets/the_ville")
)

View file

@ -40,7 +40,6 @@ async def test_gen_action_details():
sector = await GenActionSector().run(role, access_tile, act_desp)
arena = await GenActionArena().run(role, act_desp, act_world, sector)
temp_address = f"{act_world}:{sector}:{arena}"
print(temp_address)
obj = await GenActionObject().run(role, act_desp, temp_address)
act_obj_desp = await GenActObjDescription().run(role, obj, act_desp)

View file

@ -6,7 +6,7 @@ from datetime import datetime, timedelta
import pytest
from metagpt.ext.stanford_town.memory import AgentMemory
from metagpt.ext.stanford_town.memory.agent_memory import AgentMemory
from metagpt.ext.stanford_town.memory.retrieve import agent_retrieve
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH
from metagpt.logs import logger

View file

@ -2,39 +2,24 @@
# -*- coding: utf-8 -*-
# @Desc : unittest of st_plan
import pytest
from metagpt.ext.stanford_town.plan.st_plan import (
_choose_retrieved,
_should_react,
_wait_react,
)
from metagpt.ext.stanford_town.plan.st_plan import _choose_retrieved, _should_react
from tests.metagpt.ext.stanford_town.plan.test_conversation import init_two_roles
def test_should_react():
role_ir, role_km = init_two_roles()
@pytest.mark.asyncio
async def test_should_react():
role_ir, role_km = await init_two_roles()
roles = {role_ir.name: role_ir, role_km.name: role_km}
role_ir.scratch.act_address = "mock data"
observed = role_ir.observe()
observed = await role_ir.observe()
retrieved = role_ir.retrieve(observed)
focused_event = _choose_retrieved(role_ir.name, retrieved)
if focused_event:
reaction_mode = _should_react(role_ir, focused_event, roles) # chat with Isabella Rodriguez
assert "chat with" in reaction_mode
@pytest.mark.asyncio
async def test_wait_react():
role_ir, role_km = init_two_roles("base_the_ville_isabella_maria_klaus")
reaction_mode = "wait: February 13, 2023, 00:01:30"
f_daily_schedule = role_ir.scratch.f_daily_schedule
# [['sleeping', 360], ['waking up and completing her morning routine (getting out of bed)', 5], ['sleeping', 180]]
await _wait_react(role_ir, reaction_mode)
new_f_daily_schedule = role_ir.scratch.f_daily_schedule
# [['sleeping', 360], ['waking up and completing her morning routine (getting out of bed)', 5],
# ['waking up and completing her morning routine (brushing her teeth)', 5], ['sleeping', 180]]
assert len(f_daily_schedule) == len(new_f_daily_schedule)
reaction_mode = await _should_react(role_ir, focused_event, roles) # chat with Isabella Rodriguez
assert not reaction_mode