Improve type hints in kodi tests (#121508)

This commit is contained in:
epenet 2024-07-08 12:57:52 +02:00 committed by GitHub
parent b048ad8afe
commit 242b28377d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 14 deletions

View file

@ -30,7 +30,7 @@ from tests.common import MockConfigEntry
@pytest.fixture
async def user_flow(hass):
async def user_flow(hass: HomeAssistant) -> str:
"""Return a user-initiated flow after filling in host info."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -41,7 +41,7 @@ async def user_flow(hass):
return result["flow_id"]
async def test_user_flow(hass: HomeAssistant, user_flow) -> None:
async def test_user_flow(hass: HomeAssistant, user_flow: str) -> None:
"""Test a successful user initiated flow."""
with (
patch(
@ -74,7 +74,7 @@ async def test_user_flow(hass: HomeAssistant, user_flow) -> None:
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_valid_auth(hass: HomeAssistant, user_flow) -> None:
async def test_form_valid_auth(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle valid auth."""
with (
patch(
@ -124,7 +124,7 @@ async def test_form_valid_auth(hass: HomeAssistant, user_flow) -> None:
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_valid_ws_port(hass: HomeAssistant, user_flow) -> None:
async def test_form_valid_ws_port(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle valid websocket port."""
with (
patch(
@ -180,7 +180,7 @@ async def test_form_valid_ws_port(hass: HomeAssistant, user_flow) -> None:
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_empty_ws_port(hass: HomeAssistant, user_flow) -> None:
async def test_form_empty_ws_port(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle an empty websocket port input."""
with (
patch(
@ -226,7 +226,7 @@ async def test_form_empty_ws_port(hass: HomeAssistant, user_flow) -> None:
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
async def test_form_invalid_auth(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle invalid auth."""
with (
patch(
@ -322,7 +322,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
assert result["errors"] == {}
async def test_form_cannot_connect_http(hass: HomeAssistant, user_flow) -> None:
async def test_form_cannot_connect_http(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle cannot connect over HTTP error."""
with (
patch(
@ -341,7 +341,7 @@ async def test_form_cannot_connect_http(hass: HomeAssistant, user_flow) -> None:
assert result["errors"] == {"base": "cannot_connect"}
async def test_form_exception_http(hass: HomeAssistant, user_flow) -> None:
async def test_form_exception_http(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle generic exception over HTTP."""
with (
patch(
@ -360,7 +360,7 @@ async def test_form_exception_http(hass: HomeAssistant, user_flow) -> None:
assert result["errors"] == {"base": "unknown"}
async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow) -> None:
async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle cannot connect over WebSocket error."""
with (
patch(
@ -423,7 +423,7 @@ async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow) -> None:
assert result["errors"] == {"base": "cannot_connect"}
async def test_form_exception_ws(hass: HomeAssistant, user_flow) -> None:
async def test_form_exception_ws(hass: HomeAssistant, user_flow: str) -> None:
"""Test we handle generic exception over WebSocket."""
with (
patch(
@ -560,7 +560,7 @@ async def test_discovery_cannot_connect_ws(hass: HomeAssistant) -> None:
assert result["errors"] == {}
async def test_discovery_exception_http(hass: HomeAssistant, user_flow) -> None:
async def test_discovery_exception_http(hass: HomeAssistant) -> None:
"""Test we handle generic exception during discovery validation."""
with (
patch(

View file

@ -21,7 +21,7 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
@pytest.fixture
async def kodi_media_player(hass):
async def kodi_media_player(hass: HomeAssistant) -> str:
"""Get a kodi media player."""
await init_integration(hass)
return f"{MP_DOMAIN}.name"
@ -68,7 +68,7 @@ async def test_if_fires_on_state_change(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
service_calls: list[ServiceCall],
kodi_media_player,
kodi_media_player: str,
) -> None:
"""Test for turn_on and turn_off triggers firing."""
entry = entity_registry.async_get(kodi_media_player)
@ -144,7 +144,7 @@ async def test_if_fires_on_state_change_legacy(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
service_calls: list[ServiceCall],
kodi_media_player,
kodi_media_player: str,
) -> None:
"""Test for turn_on and turn_off triggers firing."""
entry = entity_registry.async_get(kodi_media_player)