Add type hints to integration tests (part 3) (#87844)

This commit is contained in:
epenet 2023-02-10 16:05:01 +01:00 committed by GitHub
parent 22bfb99db4
commit fa7acb4f0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 745 additions and 386 deletions

View file

@ -10,8 +10,10 @@ from homeassistant.components.cast.helpers import (
PlaylistSupported,
parse_playlist,
)
from homeassistant.core import HomeAssistant
from tests.common import load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.mark.parametrize(
@ -34,7 +36,9 @@ from tests.common import load_fixture
),
),
)
async def test_hls_playlist_supported(hass, aioclient_mock, url, fixture, content_type):
async def test_hls_playlist_supported(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, url, fixture, content_type
) -> None:
"""Test playlist parsing of HLS playlist."""
headers = {"content-type": content_type}
aioclient_mock.get(url, text=load_fixture(fixture, "cast"), headers=headers)
@ -96,8 +100,13 @@ async def test_hls_playlist_supported(hass, aioclient_mock, url, fixture, conten
),
)
async def test_parse_playlist(
hass, aioclient_mock, url, fixture, content_type, expected_playlist
):
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
url,
fixture,
content_type,
expected_playlist,
) -> None:
"""Test playlist parsing of HLS playlist."""
headers = {"content-type": content_type}
aioclient_mock.get(url, text=load_fixture(fixture, "cast"), headers=headers)
@ -120,7 +129,9 @@ async def test_parse_playlist(
("https://sverigesradio.se/209-hi-mp3.m3u", "empty.m3u"),
),
)
async def test_parse_bad_playlist(hass, aioclient_mock, url, fixture):
async def test_parse_bad_playlist(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, url, fixture
) -> None:
"""Test playlist parsing of HLS playlist."""
aioclient_mock.get(url, text=load_fixture(fixture, "cast"))
with pytest.raises(PlaylistError):
@ -134,7 +145,9 @@ async def test_parse_bad_playlist(hass, aioclient_mock, url, fixture):
("http://sverigesradio.se/164-hi-aac.pls", client_exceptions.ClientError),
),
)
async def test_parse_http_error(hass, aioclient_mock, url, exc):
async def test_parse_http_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, url, exc
) -> None:
"""Test playlist parsing of HLS playlist when aioclient raises."""
aioclient_mock.get(url, text="", exc=exc)
with pytest.raises(PlaylistError):