fix: adhere to CONTRIBUTING.md — ruff clean + all tests passing
- Move aiomqtt to module-level import (enables proper patch() in tests) - Remove unused variable (description) in zigbee_service — ruff F841 - Split long line (132 chars) to fit 120 char limit — ruff E501 - Fix import sort order in test files — ruff I001 - Remove unused imports (asyncio, AsyncMock, MagicMock) — ruff F401 - Rename test_mqtt_connection import alias to _test_mqtt_connection to avoid pytest fixture name collision (ERROR at setup) - All 33 backend tests now pass (21 service + 12 router) - TypeScript typecheck: 0 errors Co-authored-by: CyberKeys <noreply@openclaw.ai>
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import aiomqtt # noqa: F401
|
||||
import pytest
|
||||
|
||||
from app.services.zigbee_service import (
|
||||
@@ -14,9 +14,10 @@ from app.services.zigbee_service import (
|
||||
_z2m_type_to_homelable,
|
||||
fetch_networkmap,
|
||||
parse_networkmap,
|
||||
test_mqtt_connection,
|
||||
)
|
||||
|
||||
from app.services.zigbee_service import (
|
||||
test_mqtt_connection as _test_mqtt_connection,
|
||||
)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helper builders
|
||||
@@ -341,7 +342,7 @@ async def test_test_mqtt_connection_success() -> None:
|
||||
mock_aiomqtt.Client.return_value = _FakeClient()
|
||||
mock_aiomqtt.MqttError = Exception
|
||||
|
||||
result = await test_mqtt_connection("localhost", 1883)
|
||||
result = await _test_mqtt_connection("localhost", 1883)
|
||||
assert result is True
|
||||
|
||||
|
||||
@@ -359,4 +360,4 @@ async def test_test_mqtt_connection_failure() -> None:
|
||||
mock_aiomqtt.MqttError = Exception
|
||||
|
||||
with pytest.raises(ConnectionError):
|
||||
await test_mqtt_connection("bad-host", 1883)
|
||||
await _test_mqtt_connection("bad-host", 1883)
|
||||
|
||||
Reference in New Issue
Block a user