test: increased cb test coverage
This commit is contained in:
committed by
Luijkx,S.O.H. (Storm)
parent
de2e56ffce
commit
7f7c658901
@@ -87,3 +87,49 @@ async def test_send_beliefs_to_bdi(agent):
|
||||
assert sent.to == settings.agent_settings.bdi_core_name
|
||||
assert sent.thread == "beliefs"
|
||||
assert json.loads(sent.body)["beliefs"] == [belief.model_dump() for belief in beliefs]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_setup_executes(agent):
|
||||
"""Covers setup and asserts the agent has a name."""
|
||||
await agent.setup()
|
||||
assert agent.name == "belief_collector_agent" # simple property assertion
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_message_unrecognized_type_executes(agent):
|
||||
"""Covers the else branch for unrecognized message type."""
|
||||
payload = {"type": "unknown_type"}
|
||||
msg = make_msg(payload, sender="tester")
|
||||
# Wrap send to ensure nothing is sent
|
||||
agent.send = AsyncMock()
|
||||
await agent.handle_message(msg)
|
||||
# Assert no messages were sent
|
||||
agent.send.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_emo_text_executes(agent):
|
||||
"""Covers the _handle_emo_text method."""
|
||||
# The method does nothing, but we can assert it returns None
|
||||
result = await agent._handle_emo_text({}, "origin")
|
||||
assert result is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_beliefs_to_bdi_empty_executes(agent):
|
||||
"""Covers early return when beliefs are empty."""
|
||||
agent.send = AsyncMock()
|
||||
await agent._send_beliefs_to_bdi({})
|
||||
# Assert that nothing was sent
|
||||
agent.send.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_belief_text_invalid_returns_none(agent, mocker):
|
||||
payload = {"type": "belief_extraction_text", "beliefs": {"user_said": "invalid-argument"}}
|
||||
|
||||
result = await agent._handle_belief_text(payload, "origin")
|
||||
|
||||
# The method itself returns None
|
||||
assert result is None
|
||||
|
||||
Reference in New Issue
Block a user