test: fix tests after changing schema and

ref: N25B-299
This commit is contained in:
Twirre Meulenbelt
2025-11-24 20:53:53 +01:00
parent 3f22b854a7
commit 54502e441c
6 changed files with 74 additions and 58 deletions

View File

@@ -8,6 +8,7 @@ from control_backend.agents.bdi import (
)
from control_backend.core.agent_system import InternalMessage
from control_backend.core.config import settings
from control_backend.schemas.belief_message import Belief
@pytest.fixture
@@ -57,10 +58,11 @@ async def test_handle_message_bad_json(agent, mocker):
async def test_handle_belief_text_sends_when_beliefs_exist(agent, mocker):
payload = {"type": "belief_extraction_text", "beliefs": {"user_said": ["hello"]}}
spy = mocker.patch.object(agent, "_send_beliefs_to_bdi", new_callable=AsyncMock)
expected = [Belief(name="user_said", arguments=["hello"])]
await agent._handle_belief_text(payload, "origin")
spy.assert_awaited_once_with(payload["beliefs"], origin="origin")
spy.assert_awaited_once_with(expected, origin="origin")
@pytest.mark.asyncio
@@ -76,7 +78,7 @@ async def test_handle_belief_text_no_send_when_empty(agent, mocker):
@pytest.mark.asyncio
async def test_send_beliefs_to_bdi(agent):
agent.send = AsyncMock()
beliefs = {"user_said": ["hello", "world"]}
beliefs = [Belief(name="user_said", arguments=["hello", "world"])]
await agent._send_beliefs_to_bdi(beliefs, origin="origin")
@@ -84,4 +86,4 @@ async def test_send_beliefs_to_bdi(agent):
sent: InternalMessage = agent.send.call_args.args[0]
assert sent.to == settings.agent_settings.bdi_core_name
assert sent.thread == "beliefs"
assert json.loads(sent.body)["beliefs"] == beliefs
assert json.loads(sent.body)["beliefs"] == [belief.model_dump() for belief in beliefs]