* Implement local media finder and integrate into cast * update to media source as a platform * Tweak media source design * fix websocket and local source * fix websocket schema * fix playing media * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add resolve_media websocket * Register that shit * Square brackets * Sign path * add support for multiple media sources and address PR review * fix lint * fix tests from auto whitelisting config/media * allow specifying a name on the media source * add tests * fix for python 3.7 * Apply suggestions from code review Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * add http back to cast and remove guess_type from executor as there is no i/o Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
27 lines
994 B
Python
27 lines
994 B
Python
"""Test Media Source model methods."""
|
|
from homeassistant.components.media_source import const, models
|
|
|
|
|
|
async def test_browse_media_to_media_player_item():
|
|
"""Test BrowseMedia conversion to media player item dict."""
|
|
base = models.BrowseMedia(const.DOMAIN, "media", "media/", False, True)
|
|
base.children = [
|
|
models.BrowseMedia(
|
|
const.DOMAIN, "media/test.mp3", "test.mp3", True, False, "audio/mp3"
|
|
)
|
|
]
|
|
|
|
item = base.to_media_player_item()
|
|
assert item["title"] == "media/"
|
|
assert item["media_content_type"] == "folder"
|
|
assert item["media_content_id"] == f"{const.URI_SCHEME}{const.DOMAIN}/media"
|
|
assert not item["can_play"]
|
|
assert item["can_expand"]
|
|
assert len(item["children"]) == 1
|
|
assert item["children"][0]["title"] == "test.mp3"
|
|
|
|
|
|
async def test_media_source_default_name():
|
|
"""Test MediaSource uses domain as default name."""
|
|
source = models.MediaSource(const.DOMAIN)
|
|
assert source.name == const.DOMAIN
|