forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Velbus select platform testcases (home-assistant#134394)
- Loading branch information
Showing
3 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# serializer version: 1 | ||
# name: test_entities[select.select-entry] | ||
EntityRegistryEntrySnapshot({ | ||
'aliases': set({ | ||
}), | ||
'area_id': None, | ||
'capabilities': dict({ | ||
'options': list([ | ||
'none', | ||
'summer', | ||
'winter', | ||
'holiday', | ||
]), | ||
}), | ||
'config_entry_id': <ANY>, | ||
'device_class': None, | ||
'device_id': <ANY>, | ||
'disabled_by': None, | ||
'domain': 'select', | ||
'entity_category': <EntityCategory.CONFIG: 'config'>, | ||
'entity_id': 'select.select', | ||
'has_entity_name': False, | ||
'hidden_by': None, | ||
'icon': None, | ||
'id': <ANY>, | ||
'labels': set({ | ||
}), | ||
'name': None, | ||
'options': dict({ | ||
}), | ||
'original_device_class': None, | ||
'original_icon': None, | ||
'original_name': 'select', | ||
'platform': 'velbus', | ||
'previous_unique_id': None, | ||
'supported_features': 0, | ||
'translation_key': None, | ||
'unique_id': 'qwerty1234567-33-program_select', | ||
'unit_of_measurement': None, | ||
}) | ||
# --- | ||
# name: test_entities[select.select-state] | ||
StateSnapshot({ | ||
'attributes': ReadOnlyDict({ | ||
'friendly_name': 'select', | ||
'options': list([ | ||
'none', | ||
'summer', | ||
'winter', | ||
'holiday', | ||
]), | ||
}), | ||
'context': <ANY>, | ||
'entity_id': 'select.select', | ||
'last_changed': <ANY>, | ||
'last_reported': <ANY>, | ||
'last_updated': <ANY>, | ||
'state': 'winter', | ||
}) | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Velbus select platform tests.""" | ||
|
||
from unittest.mock import AsyncMock, patch | ||
|
||
import pytest | ||
from syrupy.assertion import SnapshotAssertion | ||
|
||
from homeassistant.components.select import ( | ||
ATTR_OPTION, | ||
DOMAIN as SELECT_DOMAIN, | ||
SERVICE_SELECT_OPTION, | ||
) | ||
from homeassistant.const import ATTR_ENTITY_ID, Platform | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import entity_registry as er | ||
|
||
from . import init_integration | ||
|
||
from tests.common import MockConfigEntry, snapshot_platform | ||
|
||
|
||
async def test_entities( | ||
hass: HomeAssistant, | ||
snapshot: SnapshotAssertion, | ||
config_entry: MockConfigEntry, | ||
entity_registry: er.EntityRegistry, | ||
) -> None: | ||
"""Test all entities.""" | ||
with patch("homeassistant.components.velbus.PLATFORMS", [Platform.SELECT]): | ||
await init_integration(hass, config_entry) | ||
|
||
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("set_program"), [("none"), ("summer"), ("winter"), ("holiday")] | ||
) | ||
async def test_select_program( | ||
hass: HomeAssistant, | ||
mock_select: AsyncMock, | ||
config_entry: MockConfigEntry, | ||
set_program: str, | ||
) -> None: | ||
"""Test program selection.""" | ||
await init_integration(hass, config_entry) | ||
await hass.services.async_call( | ||
SELECT_DOMAIN, | ||
SERVICE_SELECT_OPTION, | ||
{ATTR_ENTITY_ID: "select.select", ATTR_OPTION: set_program}, | ||
blocking=True, | ||
) | ||
mock_select.set_selected_program.assert_called_once_with(set_program) |