mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
parent
5eb50f63fd
commit
b043a6ba88
@ -55,13 +55,11 @@ OWNTONE_TYPE_TO_MEDIA_TYPE = {
|
|||||||
}
|
}
|
||||||
MEDIA_TYPE_TO_OWNTONE_TYPE = {v: k for k, v in OWNTONE_TYPE_TO_MEDIA_TYPE.items()}
|
MEDIA_TYPE_TO_OWNTONE_TYPE = {v: k for k, v in OWNTONE_TYPE_TO_MEDIA_TYPE.items()}
|
||||||
|
|
||||||
"""
|
# media_content_id is a uri in the form of SCHEMA:Title:OwnToneURI:Subtype (Subtype only used for Genre)
|
||||||
media_content_id is a uri in the form of SCHEMA:Title:OwnToneURI:Subtype (Subtype only used for Genre)
|
# OwnToneURI is in format library:type:id (for directories, id is path)
|
||||||
OwnToneURI is in format library:type:id (for directories, id is path)
|
# media_content_type - type of item (mostly used to check if playable or can expand)
|
||||||
media_content_type - type of item (mostly used to check if playable or can expand)
|
# Owntone type may differ from media_content_type when media_content_type is a directory
|
||||||
Owntone type may differ from media_content_type when media_content_type is a directory
|
# Owntone type is used in our own branching, but media_content_type is used for determining playability
|
||||||
Owntown type is used in our own branching, but media_content_type is used for determining playability
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -840,8 +840,6 @@ class ForkedDaapdMaster(MediaPlayerEntity):
|
|||||||
# This is the base level, so we combine our library with the media source
|
# This is the base level, so we combine our library with the media source
|
||||||
return library(ms_result.children)
|
return library(ms_result.children)
|
||||||
return ms_result
|
return ms_result
|
||||||
# media_content_type should only be None if media_content_id is None
|
|
||||||
assert media_content_type
|
|
||||||
return await get_owntone_content(self, media_content_id)
|
return await get_owntone_content(self, media_content_id)
|
||||||
|
|
||||||
async def async_get_browse_image(
|
async def async_get_browse_image(
|
||||||
|
@ -23,7 +23,7 @@ async def test_async_browse_media(hass, hass_ws_client, config_entry):
|
|||||||
autospec=True,
|
autospec=True,
|
||||||
) as mock_api:
|
) as mock_api:
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
||||||
@ -126,7 +126,7 @@ async def test_async_browse_media(hass, hass_ws_client, config_entry):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
# Request playlist through WebSocket
|
# Request browse root through WebSocket
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
{
|
{
|
||||||
@ -148,7 +148,6 @@ async def test_async_browse_media(hass, hass_ws_client, config_entry):
|
|||||||
nonlocal msg_id
|
nonlocal msg_id
|
||||||
for child in children:
|
for child in children:
|
||||||
if child["can_expand"]:
|
if child["can_expand"]:
|
||||||
print("EXPANDING CHILD", child)
|
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
{
|
{
|
||||||
"id": msg_id,
|
"id": msg_id,
|
||||||
@ -177,7 +176,7 @@ async def test_async_browse_media_not_found(hass, hass_ws_client, config_entry):
|
|||||||
autospec=True,
|
autospec=True,
|
||||||
) as mock_api:
|
) as mock_api:
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
mock_api.return_value.get_directory.return_value = None
|
mock_api.return_value.get_directory.return_value = None
|
||||||
@ -186,7 +185,7 @@ async def test_async_browse_media_not_found(hass, hass_ws_client, config_entry):
|
|||||||
mock_api.return_value.get_genres.return_value = None
|
mock_api.return_value.get_genres.return_value = None
|
||||||
mock_api.return_value.get_playlists.return_value = None
|
mock_api.return_value.get_playlists.return_value = None
|
||||||
|
|
||||||
# Request playlist through WebSocket
|
# Request different types of media through WebSocket
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
msg_id = 1
|
msg_id = 1
|
||||||
for media_type in (
|
for media_type in (
|
||||||
@ -229,7 +228,7 @@ async def test_async_browse_image(hass, hass_client, config_entry):
|
|||||||
autospec=True,
|
autospec=True,
|
||||||
) as mock_api:
|
) as mock_api:
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
client = await hass_client()
|
client = await hass_client()
|
||||||
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
||||||
@ -279,7 +278,7 @@ async def test_async_browse_image_missing(hass, hass_client, config_entry, caplo
|
|||||||
autospec=True,
|
autospec=True,
|
||||||
) as mock_api:
|
) as mock_api:
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
client = await hass_client()
|
client = await hass_client()
|
||||||
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
mock_api.return_value.full_url = lambda x: "http://owntone_instance/" + x
|
||||||
|
@ -225,7 +225,7 @@ async def test_options_flow(hass, config_entry):
|
|||||||
) as mock_get_request:
|
) as mock_get_request:
|
||||||
mock_get_request.return_value = SAMPLE_CONFIG
|
mock_get_request.return_value = SAMPLE_CONFIG
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
@ -315,7 +315,7 @@ async def mock_api_object_fixture(hass, config_entry, get_request_return_values)
|
|||||||
mock_api.return_value.get_pipes.return_value = SAMPLE_PIPES
|
mock_api.return_value.get_pipes.return_value = SAMPLE_PIPES
|
||||||
mock_api.return_value.get_playlists.return_value = SAMPLE_PLAYLISTS
|
mock_api.return_value.get_playlists.return_value = SAMPLE_PLAYLISTS
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
mock_api.return_value.start_websocket_handler.assert_called_once()
|
mock_api.return_value.start_websocket_handler.assert_called_once()
|
||||||
@ -775,7 +775,7 @@ async def test_invalid_websocket_port(hass, config_entry):
|
|||||||
) as mock_api:
|
) as mock_api:
|
||||||
mock_api.return_value.get_request.return_value = SAMPLE_CONFIG_NO_WEBSOCKET
|
mock_api.return_value.get_request.return_value = SAMPLE_CONFIG_NO_WEBSOCKET
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await config_entry.async_setup(hass)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.states.get(TEST_MASTER_ENTITY_NAME).state == STATE_UNAVAILABLE
|
assert hass.states.get(TEST_MASTER_ENTITY_NAME).state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user