Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tessie honk button #106518

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/tessie/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TessieButtonEntityDescription(ButtonEntityDescription):
TessieButtonEntityDescription(
key="flash_lights", func=lambda: flash_lights, icon="mdi:flashlight"
),
TessieButtonEntityDescription(key="honk", func=honk, icon="mdi:bullhorn"),
TessieButtonEntityDescription(key="honk", func=lambda: honk, icon="mdi:bullhorn"),
TessieButtonEntityDescription(
key="trigger_homelink", func=lambda: trigger_homelink, icon="mdi:garage"
),
Expand Down
19 changes: 16 additions & 3 deletions tests/components/tessie/test_button.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
"""Test the Tessie button platform."""
from unittest.mock import patch

import pytest

from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant

from .common import setup_platform


async def test_buttons(hass: HomeAssistant) -> None:
@pytest.mark.parametrize(
("entity_id", "func"),
[
("button.test_wake", "wake"),
("button.test_flash_lights", "flash_lights"),
("button.test_honk_horn", "honk"),
("button.test_homelink", "trigger_homelink"),
("button.test_keyless_driving", "enable_keyless_driving"),
("button.test_play_fart", "boombox"),
],
)
async def test_buttons(hass: HomeAssistant, entity_id, func) -> None:
"""Tests that the button entities are correct."""

await setup_platform(hass)

# Test wake button
with patch(
"homeassistant.components.tessie.button.wake",
f"homeassistant.components.tessie.button.{func}",
) as mock_wake:
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: ["button.test_wake"]},
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_wake.assert_called_once()