Skip to content

Instantly share code, notes, and snippets.

@jbouwh
Created July 21, 2021 13:15
Show Gist options
  • Select an option

  • Save jbouwh/3465f95ed50f3e64bc1c626f16be7b46 to your computer and use it in GitHub Desktop.

Select an option

Save jbouwh/3465f95ed50f3e64bc1c626f16be7b46 to your computer and use it in GitHub Desktop.
tests/components/select
"""The tests for the Select component."""
from unittest.mock import MagicMock
import pytest
from homeassistant.components.select import (
ATTR_OPTION,
ATTR_OPTIONS,
SelectEntity,
DOMAIN,
SERVICE_SELECT_OPTION,
)
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.const import (
ATTR_ENTITY_ID,
)
from tests.testing_config.custom_components.test.select import (
UNIQUE_SELECT_1,
UNIQUE_SELECT_2,
UNIQUE_SELECT_3,
MockSelectEntity,
)
from tests.common import (
MockConfigEntry,
mock_registry,
)
@pytest.fixture
def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass)
async def test_select(hass, caplog, entity_reg):
"""Test getting data from the mocked select entity."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"platform": "test"}})
await hass.async_block_till_done()
# Would expect state woeld not be None
state = hass.states.get("select.select_1")
assert state is None
# But the test passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment