Skip to content

Commit 3006392

Browse files
committed
chore: Enable verbose logging in CI
1 parent e487de8 commit 3006392

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: poetry install
5151
shell: bash
5252
- name: Test with Pytest
53-
run: poetry run pytest
53+
run: poetry run pytest --log-level=DEBUG -vv -s
5454
shell: bash
5555
release:
5656
runs-on: ubuntu-latest

tests/devices/test_mqtt_channel.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import json
5+
import logging
56
from collections.abc import Callable, Generator
67
from unittest.mock import AsyncMock, Mock, patch
78

@@ -82,6 +83,15 @@ async def setup_message_handler(mqtt_session: Mock, mqtt_channel: MqttChannel) -
8283
return message_handler
8384

8485

86+
@pytest.fixture
87+
def warning_caplog(
88+
caplog: pytest.LogCaptureFixture,
89+
) -> Generator[pytest.LogCaptureFixture]:
90+
"""Fixture to capture warning messages."""
91+
caplog.set_level(logging.WARNING)
92+
yield caplog
93+
94+
8595
async def home_home_data_no_devices() -> HomeData:
8696
"""Mock home data API that returns no devices."""
8797
return HomeData(
@@ -163,7 +173,7 @@ async def test_concurrent_commands(
163173
mqtt_session: Mock,
164174
mqtt_channel: MqttChannel,
165175
mqtt_message_handler: Callable[[bytes], None],
166-
caplog: pytest.LogCaptureFixture,
176+
warning_caplog: pytest.LogCaptureFixture,
167177
) -> None:
168178
"""Test handling multiple concurrent RPC commands."""
169179

@@ -187,7 +197,7 @@ async def test_concurrent_commands(
187197
assert result1 == TEST_RESPONSE
188198
assert result2 == TEST_RESPONSE2
189199

190-
assert not caplog.records
200+
assert not warning_caplog.records
191201

192202

193203
async def test_concurrent_commands_same_request_id(

tests/test_api.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ async def connected_mqtt_client_fixture(
142142
response_queue.put(mqtt_packet.gen_suback(1, 0))
143143
await mqtt_client.async_connect()
144144
yield mqtt_client
145-
145+
if mqtt_client.is_connected():
146+
try:
147+
await mqtt_client.async_disconnect()
148+
except Exception:
149+
pass
146150

147151
async def test_async_connect(received_requests: Queue, connected_mqtt_client: RoborockMqttClientV1) -> None:
148152
"""Test connecting to the MQTT broker."""
@@ -173,6 +177,28 @@ async def test_connect_failure_response(
173177
assert received_requests.qsize() == 1 # Connect attempt
174178

175179

180+
async def test_disconnect_already_disconnected(connected_mqtt_client: RoborockMqttClientV1) -> None:
181+
"""Test the MQTT client error handling for a no-op disconnect."""
182+
183+
assert connected_mqtt_client.is_connected()
184+
185+
# Make the MQTT client simulate returning that it already thinks it is disconnected
186+
with patch("roborock.cloud_api.mqtt.Client.disconnect", return_value=mqtt.MQTT_ERR_NO_CONN):
187+
await connected_mqtt_client.async_disconnect()
188+
189+
190+
async def test_disconnect_failure(connected_mqtt_client: RoborockMqttClientV1) -> None:
191+
"""Test that the MQTT client ignores MQTT client error handling for a no-op disconnect."""
192+
193+
assert connected_mqtt_client.is_connected()
194+
195+
# Make the MQTT client returns with an error when disconnecting
196+
with patch("roborock.cloud_api.mqtt.Client.disconnect", return_value=mqtt.MQTT_ERR_PROTOCOL), pytest.raises(
197+
RoborockException, match="Failed to disconnect"
198+
):
199+
await connected_mqtt_client.async_disconnect()
200+
201+
176202
async def test_disconnect_failure_response(
177203
received_requests: Queue,
178204
response_queue: Queue,

0 commit comments

Comments
 (0)