Skip to content

Commit

Permalink
Improve type hints in kodi tests (home-assistant#121508)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jul 8, 2024
1 parent b048ad8 commit 242b283
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions tests/components/kodi/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


@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}
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions tests/components/kodi/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 242b283

Please sign in to comment.