Improve Google Cast detection of HLS playlists (#71564)

This commit is contained in:
Erik Montnemery 2022-05-09 13:57:32 +02:00 committed by GitHub
parent 524920dd2e
commit d284e579bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View file

@ -14,10 +14,25 @@ from homeassistant.components.cast.helpers import (
from tests.common import load_fixture
async def test_hls_playlist_supported(hass, aioclient_mock):
@pytest.mark.parametrize(
"url,fixture,content_type",
(
(
"http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_radio_fourfm.m3u8",
"bbc_radio_fourfm.m3u8",
None,
),
(
"https://rthkaudio2-lh.akamaihd.net/i/radio2_1@355865/master.m3u8",
"rthkaudio2.m3u8",
"application/vnd.apple.mpegurl",
),
),
)
async def test_hls_playlist_supported(hass, aioclient_mock, url, fixture, content_type):
"""Test playlist parsing of HLS playlist."""
url = "http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_radio_fourfm.m3u8"
aioclient_mock.get(url, text=load_fixture("bbc_radio_fourfm.m3u8", "cast"))
headers = {"content-type": content_type}
aioclient_mock.get(url, text=load_fixture(fixture, "cast"), headers=headers)
with pytest.raises(PlaylistSupported):
await parse_playlist(hass, url)