chore: remove caplog from test cases

This commit is contained in:
Björn Otgaar
2025-11-17 16:04:54 +01:00
parent debc87c0bb
commit 41993a902b
2 changed files with 11 additions and 13 deletions

View File

@@ -73,7 +73,7 @@ async def test_send_commands_behaviour_valid_message():
@pytest.mark.asyncio
async def test_send_commands_behaviour_invalid_message(caplog):
async def test_send_commands_behaviour_invalid_message():
"""Test behaviour with invalid JSON message triggers error logging"""
fake_socket = AsyncMock()
fake_socket.recv_multipart = AsyncMock(return_value=(b"command", b"{invalid_json}"))
@@ -86,9 +86,7 @@ async def test_send_commands_behaviour_invalid_message(caplog):
behaviour = agent.SendCommandsBehaviour()
behaviour.agent = agent
with caplog.at_level("ERROR"):
await behaviour.run()
await behaviour.run()
fake_socket.recv_multipart.assert_awaited()
fake_socket.send_json.assert_not_awaited()
assert "Error processing message" in caplog.text

View File

@@ -176,7 +176,7 @@ async def test_setup_creates_socket_and_negotiate_2(zmq_context):
@pytest.mark.asyncio
async def test_setup_creates_socket_and_negotiate_3(zmq_context, caplog):
async def test_setup_creates_socket_and_negotiate_3(zmq_context):
"""
Test the functionality of setup with incorrect negotiation message
"""
@@ -340,7 +340,7 @@ async def test_setup_creates_socket_and_negotiate_6(zmq_context):
@pytest.mark.asyncio
async def test_setup_creates_socket_and_negotiate_7(zmq_context, caplog):
async def test_setup_creates_socket_and_negotiate_7(zmq_context):
"""
Test the functionality of setup with incorrect id
"""
@@ -379,7 +379,7 @@ async def test_setup_creates_socket_and_negotiate_7(zmq_context, caplog):
@pytest.mark.asyncio
async def test_setup_creates_socket_and_negotiate_timeout(zmq_context, caplog):
async def test_setup_creates_socket_and_negotiate_timeout(zmq_context):
"""
Test the functionality of setup with incorrect negotiation message
"""
@@ -416,7 +416,7 @@ async def test_setup_creates_socket_and_negotiate_timeout(zmq_context, caplog):
@pytest.mark.asyncio
async def test_listen_behaviour_ping_correct(caplog):
async def test_listen_behaviour_ping_correct():
fake_socket = AsyncMock()
fake_socket.send_json = AsyncMock()
fake_socket.recv_json = AsyncMock(return_value={"endpoint": "ping", "data": {}})
@@ -436,7 +436,7 @@ async def test_listen_behaviour_ping_correct(caplog):
@pytest.mark.asyncio
async def test_listen_behaviour_ping_wrong_endpoint(caplog):
async def test_listen_behaviour_ping_wrong_endpoint():
"""
Test if our listen behaviour can work with wrong messages (wrong endpoint)
"""
@@ -471,7 +471,7 @@ async def test_listen_behaviour_ping_wrong_endpoint(caplog):
@pytest.mark.asyncio
async def test_listen_behaviour_timeout(zmq_context, caplog):
async def test_listen_behaviour_timeout(zmq_context):
fake_socket = zmq_context.return_value.socket.return_value
fake_socket.send_json = AsyncMock()
# recv_json will never resolve, simulate timeout
@@ -491,7 +491,7 @@ async def test_listen_behaviour_timeout(zmq_context, caplog):
@pytest.mark.asyncio
async def test_listen_behaviour_ping_no_endpoint(caplog):
async def test_listen_behaviour_ping_no_endpoint():
"""
Test if our listen behaviour can work with wrong messages (wrong endpoint)
"""
@@ -520,7 +520,7 @@ async def test_listen_behaviour_ping_no_endpoint(caplog):
@pytest.mark.asyncio
async def test_setup_unexpected_exception(zmq_context, caplog):
async def test_setup_unexpected_exception(zmq_context):
fake_socket = zmq_context.return_value.socket.return_value
fake_socket.send_json = AsyncMock()
# Simulate unexpected exception during recv_json()
@@ -541,7 +541,7 @@ async def test_setup_unexpected_exception(zmq_context, caplog):
@pytest.mark.asyncio
async def test_setup_unpacking_exception(zmq_context, caplog):
async def test_setup_unpacking_exception(zmq_context):
# --- Arrange ---
fake_socket = zmq_context.return_value.socket.return_value
fake_socket.send_json = AsyncMock()