Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/linkplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ async def session_call_api_json(
return json.loads(result) # type: ignore
except json.JSONDecodeError as jsonexc:
url = API_ENDPOINT.format(endpoint, command)
LOGGER.warning("Unexpected json for %s: %s", url, jsonexc)
# WiiM devices answer "Failed" to getMetaInfo when nothing is loaded
if result == "Failed":
LOGGER.debug("Unexpected json for %s: %s", url, jsonexc)
else:
LOGGER.warning("Unexpected json for %s: %s", url, jsonexc)
raise LinkPlayInvalidDataException(
message=f"Unexpected JSON ({result}) received from '{url}'", data=result
) from jsonexc
Expand Down
6 changes: 5 additions & 1 deletion tests/linkplay/test_bridge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test bridge functionality."""

import logging
from typing import Any
from unittest.mock import AsyncMock, MagicMock, Mock, patch

Expand Down Expand Up @@ -565,7 +566,7 @@ async def test_update_status_does_not_trigger_controller_on_no_mode_change(mock_
mock_bridge.device.controller.assert_not_called()


async def test_meta_info_failed_handling():
async def test_meta_info_failed_handling(caplog: pytest.LogCaptureFixture):
"""Test that the player handles a failed META_INFO request correctly."""

async def mock_session_call_api_json_side_effect(endpoint, session, command):
Expand Down Expand Up @@ -601,6 +602,9 @@ async def mock_session_call_api_json_side_effect(endpoint, session, command):
# Verify that the mocked function was called with the correct command
mock_api.assert_called_with("http://1.2.3.4", None, LinkPlayCommand.META_INFO)

# Verify that the expected "Failed" answer is not logged as a warning
assert not [r for r in caplog.records if r.levelno >= logging.WARNING]


async def test_audio_output_control():
"""Test that the player handles a audio output control correctly."""
Expand Down