Skip to content
Merged
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
1 change: 1 addition & 0 deletions homeassistant/components/matter/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
(0x0001, 0x0108),
(0x0001, 0x010A),
(0x0001, 0x013F),
(0x118C, 0x2022),
(0x1209, 0x8000),
(0x1209, 0x8001),
(0x1209, 0x8002),
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ps4/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _parse_status(self) -> None:
self._attr_source = self._attr_media_title
self._attr_media_content_type = None
# Get data from PS Store.
self.hass.async_create_background_task(
self.hass.create_task(
self.async_get_title_data(title_id, name),
"ps4.media_player-get_title_data",
)
Expand Down
18 changes: 14 additions & 4 deletions tests/components/forked_daapd/test_browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,13 @@ async def test_async_browse_spotify(
assert await async_setup_component(hass, spotify.DOMAIN, {})
await hass.async_block_till_done()
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.forked_daapd.ForkedDaapdAPI",
autospec=True,
) as mock_api:
mock_api.return_value.get_request.return_value = {"websocket_port": 2}
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.forked_daapd.media_player.spotify_async_browse_media"
) as mock_spotify_browse:
Expand Down Expand Up @@ -325,8 +330,13 @@ async def test_async_browse_media_source(
"""Test browsing media_source."""

config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.forked_daapd.ForkedDaapdAPI",
autospec=True,
) as mock_api:
mock_api.return_value.get_request.return_value = {"websocket_port": 2}
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.forked_daapd.media_player.media_source.async_browse_media"
) as mock_media_source_browse:
Expand Down
3 changes: 3 additions & 0 deletions tests/components/go2rtc/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,11 @@ async def test_setup_with_setup_error(
caplog: pytest.LogCaptureFixture,
has_go2rtc_entry: bool,
expected_log_message: str,
rest_client: AsyncMock,
) -> None:
"""Test setup integration fails."""
# The cases that get as far as starting the server expect it to fail
rest_client.validate_server_version.side_effect = Go2RtcClientError()

assert not await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done(wait_background_tasks=True)
Expand Down
8 changes: 4 additions & 4 deletions tests/components/icloud/test_media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from base64 import b64encode
from http import HTTPStatus
from types import SimpleNamespace
from unittest.mock import PropertyMock, patch
from unittest.mock import MagicMock, PropertyMock, patch
import urllib.parse

from aiohttp import hdrs
Expand Down Expand Up @@ -793,7 +793,7 @@ async def iter_chunked(self, _size: int):
hdrs.CONTENT_LENGTH: "6",
}
upstream_resp.content = _Content()
upstream_resp.release.return_value = None
upstream_resp.release = MagicMock(return_value=None)

mock_session = AsyncMock()
mock_session.get.return_value = upstream_resp
Expand Down Expand Up @@ -855,7 +855,7 @@ async def iter_chunked(self, _size: int):
hdrs.CONTENT_LENGTH: "6",
}
upstream_resp.content = _Content()
upstream_resp.release.return_value = None
upstream_resp.release = MagicMock(return_value=None)

mock_session = AsyncMock()
mock_session.get.return_value = upstream_resp
Expand Down Expand Up @@ -931,7 +931,7 @@ def mock_get(url, *args, **kwargs):
upstream_resp.content = _Content(
int(upstream_resp.headers[hdrs.CONTENT_LENGTH])
)
upstream_resp.release.return_value = None
upstream_resp.release = MagicMock(return_value=None)
return upstream_resp

mock_session = AsyncMock()
Expand Down
29 changes: 29 additions & 0 deletions tests/components/ps4/test_media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,32 @@ async def test_entry_is_unloaded(hass: HomeAssistant) -> None:
assert not hass.data[PS4_DATA].protocol.callbacks

assert hass.states.get(mock_entity_id) is None


async def test_title_data_fetched_from_poll(
hass: HomeAssistant, patch_get_status: MagicMock
) -> None:
"""Test title data is fetched when parsing status in an executor thread."""
patch_get_status.return_value = MOCK_STATUS_PLAYING

mock_result = MagicMock()
mock_result.name = MOCK_TITLE_NAME
mock_result.cover_art = MOCK_TITLE_ART_URL
mock_result.game_type = "not_an_app"

mock_func = (
"homeassistant.components.ps4.media_player"
".pyps4.Ps4Async.async_get_ps_store_data"
)
with patch(mock_func, return_value=mock_result) as mock_fetch:
mock_entity_id = await setup_mock_component(hass)
await hass.async_block_till_done(wait_background_tasks=True)

assert len(mock_fetch.mock_calls) == 1

mock_state = hass.states.get(mock_entity_id)
mock_attrs = dict(mock_state.attributes)

assert mock_state.state == STATE_PLAYING
assert mock_attrs.get(ATTR_MEDIA_TITLE) == MOCK_TITLE_NAME
assert mock_attrs.get(ATTR_MEDIA_CONTENT_TYPE) == MOCK_TITLE_TYPE
Loading