init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1 @@
"""A collection of custom integrations used when running tests."""

View File

@@ -0,0 +1 @@
"""Custom platform for a built-in component, should not be allowed."""

View File

@@ -0,0 +1,6 @@
extend = "../../ruff.toml"
[lint]
extend-ignore = [
"INP001", # File is part of an implicit namespace package. Add an `__init__.py`.
]

View File

@@ -0,0 +1 @@
"""Test switch platform for test_embedded component."""

View File

@@ -0,0 +1 @@
"""An integration with several platforms used with unit tests."""

View File

@@ -0,0 +1,41 @@
"""Provide a mock remote platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.camera import Camera, CameraEntityFeature, StreamType
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Return mock entities."""
async_add_entities_callback(
[AttrFrontendStreamTypeCamera(), PropertyFrontendStreamTypeCamera()]
)
class AttrFrontendStreamTypeCamera(Camera):
"""attr frontend stream type Camera."""
_attr_name = "attr frontend stream type"
_attr_supported_features: CameraEntityFeature = CameraEntityFeature.STREAM
_attr_frontend_stream_type: StreamType = StreamType.WEB_RTC
class PropertyFrontendStreamTypeCamera(Camera):
"""property frontend stream type Camera."""
_attr_name = "property frontend stream type"
_attr_supported_features: CameraEntityFeature = CameraEntityFeature.STREAM
@property
def frontend_stream_type(self) -> StreamType | None:
"""Return the stream type of the camera."""
return StreamType.WEB_RTC

View File

@@ -0,0 +1,12 @@
{
"entity": {
"switch": {
"something": {
"state": {
"away": "mdi:home-outline",
"home": "mdi:home"
}
}
}
}
}

View File

@@ -0,0 +1,57 @@
"""Provide a mock image processing."""
from homeassistant.components.image_processing import ImageProcessingEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the test image_processing platform."""
async_add_entities_callback([TestImageProcessing("camera.demo_camera", "Test")])
class TestImageProcessing(ImageProcessingEntity):
"""Test image processing entity."""
def __init__(self, camera_entity, name) -> None:
"""Initialize test image processing."""
self._name = name
self._camera = camera_entity
self._count = 0
self._image = ""
@property
def should_poll(self):
"""Return True if entity has to be polled for state."""
return False
@property
def camera_entity(self):
"""Return camera entity id from process pictures."""
return self._camera
@property
def name(self):
"""Return the name of the entity."""
return self._name
@property
def state(self):
"""Return the state of the entity."""
return self._count
@property
def extra_state_attributes(self):
"""Return device specific state attributes."""
return {"image": self._image}
def process_image(self, image):
"""Process image."""
self._image = image
self._count += 1

View File

@@ -0,0 +1,103 @@
"""Provide a mock light platform.
Call init before using it in your tests to ensure clean test data.
"""
from typing import Any, Literal
from homeassistant.components.light import ColorMode, LightEntity
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from tests.common import MockToggleEntity
ENTITIES = []
def init(empty=False):
"""Initialize the platform with entities."""
# pylint: disable-next=global-statement
global ENTITIES # noqa: PLW0603
ENTITIES = (
[]
if empty
else [
MockLight("Ceiling", STATE_ON),
MockLight("Ceiling", STATE_OFF),
MockLight(None, STATE_OFF),
]
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Return mock entities."""
async_add_entities_callback(ENTITIES)
TURN_ON_ARG_TO_COLOR_MODE = {
"hs_color": ColorMode.HS,
"xy_color": ColorMode.XY,
"rgb_color": ColorMode.RGB,
"rgbw_color": ColorMode.RGBW,
"rgbww_color": ColorMode.RGBWW,
"color_temp_kelvin": ColorMode.COLOR_TEMP,
}
class MockLight(MockToggleEntity, LightEntity):
"""Mock light class."""
_attr_max_color_temp_kelvin = 6500
_attr_min_color_temp_kelvin = 2000
supported_features = 0
brightness = None
color_temp_kelvin = None
hs_color = None
rgb_color = None
rgbw_color = None
rgbww_color = None
xy_color = None
def __init__(
self,
name: str | None,
state: Literal["on", "off"] | None,
supported_color_modes: set[ColorMode] | None = None,
) -> None:
"""Initialize the mock light."""
super().__init__(name, state)
if supported_color_modes is None:
supported_color_modes = {ColorMode.ONOFF}
self._attr_supported_color_modes = supported_color_modes
color_mode = ColorMode.UNKNOWN
if len(supported_color_modes) == 1:
color_mode = next(iter(supported_color_modes))
self._attr_color_mode = color_mode
def turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
super().turn_on(**kwargs)
for key, value in kwargs.items():
if key in [
"brightness",
"hs_color",
"xy_color",
"rgb_color",
"rgbw_color",
"rgbww_color",
"color_temp_kelvin",
]:
setattr(self, key, value)
if key == "white":
setattr(self, "brightness", value)
if key in TURN_ON_ARG_TO_COLOR_MODE:
self._attr_color_mode = TURN_ON_ARG_TO_COLOR_MODE[key]

View File

@@ -0,0 +1,67 @@
"""Provide a mock lock platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.lock import LockEntity, LockEntityFeature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from tests.common import MockEntity
ENTITIES = {}
def init(empty=False):
"""Initialize the platform with entities."""
# pylint: disable-next=global-statement
global ENTITIES # noqa: PLW0603
ENTITIES = (
{}
if empty
else {
"support_open": MockLock(
name="Support open Lock",
is_locked=True,
supported_features=LockEntityFeature.OPEN,
unique_id="unique_support_open",
),
"no_support_open": MockLock(
name="No support open Lock",
is_locked=True,
supported_features=0,
unique_id="unique_no_support_open",
),
}
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Return mock entities."""
async_add_entities_callback(list(ENTITIES.values()))
class MockLock(MockEntity, LockEntity):
"""Mock Lock class."""
@property
def code_format(self) -> str | None:
"""Return code format."""
return self._handle("code_format")
@property
def is_locked(self):
"""Return true if the lock is locked."""
return self._handle("is_locked")
@property
def supported_features(self):
"""Return the class of this sensor."""
return self._handle("supported_features")

View File

@@ -0,0 +1,9 @@
{
"domain": "test",
"name": "Test Components",
"documentation": "http://example.com",
"requirements": [],
"dependencies": [],
"codeowners": [],
"version": "1.2.3"
}

View File

@@ -0,0 +1,46 @@
"""Provide a mock remote platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.remote import RemoteEntity
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from tests.common import MockToggleEntity
ENTITIES = []
def init(empty=False):
"""Initialize the platform with entities."""
# pylint: disable-next=global-statement
global ENTITIES # noqa: PLW0603
ENTITIES = (
[]
if empty
else [
MockRemote("TV", STATE_ON),
MockRemote("DVD", STATE_OFF),
MockRemote(None, STATE_OFF),
]
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Return mock entities."""
async_add_entities_callback(ENTITIES)
class MockRemote(MockToggleEntity, RemoteEntity):
"""Mock remote class."""
supported_features = 0

View File

@@ -0,0 +1,15 @@
"""Stub switch platform for translation tests."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Stub setup for translation tests."""
async_add_entities_callback([])

View File

@@ -0,0 +1,13 @@
{
"entity": {
"switch": {
"other1": {
"name": "Anderes 1",
"unit_of_measurement": "einheiten"
},
"other2": { "name": "Anderes 2 {placeholder}" },
"other3": { "name": "" },
"outlet": { "name": "Steckdose {something}" }
}
}
}

View File

@@ -0,0 +1,15 @@
{
"entity": {
"switch": {
"other1": { "name": "Other 1", "unit_of_measurement": "units" },
"other2": { "name": "Other 2" },
"other3": { "name": "Other 3" },
"other4": {
"name": "Other 4",
"unit_of_measurement": "quantities"
},
"outlet": { "name": "Outlet {placeholder}" }
}
},
"something": "else"
}

View File

@@ -0,0 +1,11 @@
{
"entity": {
"switch": {
"other1": { "name": "Otra 1" },
"other2": { "name": "Otra 2" },
"other3": { "name": "Otra 3" },
"other4": { "name": "Otra 4" },
"outlet": { "name": "Enchufe {placeholder}" }
}
}
}

View File

@@ -0,0 +1,217 @@
"""Provide a mock weather platform.
Call init before using it in your tests to ensure clean test data.
"""
from __future__ import annotations
from typing import Any
from homeassistant.components.weather import (
ATTR_FORECAST_CLOUD_COVERAGE,
ATTR_FORECAST_HUMIDITY,
ATTR_FORECAST_IS_DAYTIME,
ATTR_FORECAST_NATIVE_APPARENT_TEMP,
ATTR_FORECAST_NATIVE_DEW_POINT,
ATTR_FORECAST_NATIVE_PRECIPITATION,
ATTR_FORECAST_NATIVE_PRESSURE,
ATTR_FORECAST_NATIVE_TEMP,
ATTR_FORECAST_NATIVE_TEMP_LOW,
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED,
ATTR_FORECAST_NATIVE_WIND_SPEED,
ATTR_FORECAST_UV_INDEX,
ATTR_FORECAST_WIND_BEARING,
Forecast,
WeatherEntity,
)
from homeassistant.core import HomeAssistant
from tests.common import MockEntity
ENTITIES = []
def init(empty=False):
"""Initialize the platform with entities."""
# pylint: disable-next=global-statement
global ENTITIES # noqa: PLW0603
ENTITIES = [] if empty else [MockWeather()]
async def async_setup_platform(
hass: HomeAssistant, config, async_add_entities_callback, discovery_info=None
):
"""Return mock entities."""
async_add_entities_callback(ENTITIES)
class MockWeather(MockEntity, WeatherEntity):
"""Mock weather class."""
@property
def native_temperature(self) -> float | None:
"""Return the platform temperature."""
return self._handle("native_temperature")
@property
def native_apparent_temperature(self) -> float | None:
"""Return the platform apparent temperature."""
return self._handle("native_apparent_temperature")
@property
def native_dew_point(self) -> float | None:
"""Return the platform dewpoint temperature."""
return self._handle("native_dew_point")
@property
def native_temperature_unit(self) -> str | None:
"""Return the unit of measurement for temperature."""
return self._handle("native_temperature_unit")
@property
def native_pressure(self) -> float | None:
"""Return the pressure."""
return self._handle("native_pressure")
@property
def native_pressure_unit(self) -> str | None:
"""Return the unit of measurement for pressure."""
return self._handle("native_pressure_unit")
@property
def humidity(self) -> float | None:
"""Return the humidity."""
return self._handle("humidity")
@property
def native_wind_gust_speed(self) -> float | None:
"""Return the wind speed."""
return self._handle("native_wind_gust_speed")
@property
def native_wind_speed(self) -> float | None:
"""Return the wind speed."""
return self._handle("native_wind_speed")
@property
def native_wind_speed_unit(self) -> str | None:
"""Return the unit of measurement for wind speed."""
return self._handle("native_wind_speed_unit")
@property
def wind_bearing(self) -> float | str | None:
"""Return the wind bearing."""
return self._handle("wind_bearing")
@property
def ozone(self) -> float | None:
"""Return the ozone level."""
return self._handle("ozone")
@property
def cloud_coverage(self) -> float | None:
"""Return the cloud coverage in %."""
return self._handle("cloud_coverage")
@property
def uv_index(self) -> float | None:
"""Return the UV index."""
return self._handle("uv_index")
@property
def native_visibility(self) -> float | None:
"""Return the visibility."""
return self._handle("native_visibility")
@property
def native_visibility_unit(self) -> str | None:
"""Return the unit of measurement for visibility."""
return self._handle("native_visibility_unit")
@property
def native_precipitation_unit(self) -> str | None:
"""Return the native unit of measurement for accumulated precipitation."""
return self._handle("native_precipitation_unit")
@property
def condition(self) -> str | None:
"""Return the current condition."""
return self._handle("condition")
@property
def precision(self) -> float:
"""Return the precision of the temperature."""
return self._handle("precision")
class MockWeatherMockForecast(MockWeather):
"""Mock weather class with mocked forecast."""
def __init__(self, **values: Any) -> None:
"""Initialize."""
super().__init__(**values)
self.forecast_list: list[Forecast] | None = [
{
ATTR_FORECAST_NATIVE_TEMP: self.native_temperature,
ATTR_FORECAST_NATIVE_APPARENT_TEMP: self.native_apparent_temperature,
ATTR_FORECAST_NATIVE_TEMP_LOW: self.native_temperature,
ATTR_FORECAST_NATIVE_DEW_POINT: self.native_dew_point,
ATTR_FORECAST_CLOUD_COVERAGE: self.cloud_coverage,
ATTR_FORECAST_NATIVE_PRESSURE: self.native_pressure,
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: self.native_wind_gust_speed,
ATTR_FORECAST_NATIVE_WIND_SPEED: self.native_wind_speed,
ATTR_FORECAST_WIND_BEARING: self.wind_bearing,
ATTR_FORECAST_UV_INDEX: self.uv_index,
ATTR_FORECAST_NATIVE_PRECIPITATION: self._values.get(
"native_precipitation"
),
ATTR_FORECAST_HUMIDITY: self.humidity,
}
]
async def async_forecast_daily(self) -> list[Forecast] | None:
"""Return the forecast_daily."""
return self.forecast_list
async def async_forecast_twice_daily(self) -> list[Forecast] | None:
"""Return the forecast_twice_daily."""
return [
{
ATTR_FORECAST_NATIVE_TEMP: self.native_temperature,
ATTR_FORECAST_NATIVE_APPARENT_TEMP: self.native_apparent_temperature,
ATTR_FORECAST_NATIVE_TEMP_LOW: self.native_temperature,
ATTR_FORECAST_NATIVE_DEW_POINT: self.native_dew_point,
ATTR_FORECAST_CLOUD_COVERAGE: self.cloud_coverage,
ATTR_FORECAST_NATIVE_PRESSURE: self.native_pressure,
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: self.native_wind_gust_speed,
ATTR_FORECAST_NATIVE_WIND_SPEED: self.native_wind_speed,
ATTR_FORECAST_WIND_BEARING: self.wind_bearing,
ATTR_FORECAST_UV_INDEX: self.uv_index,
ATTR_FORECAST_NATIVE_PRECIPITATION: self._values.get(
"native_precipitation"
),
ATTR_FORECAST_HUMIDITY: self.humidity,
ATTR_FORECAST_IS_DAYTIME: self._values.get("is_daytime"),
}
]
async def async_forecast_hourly(self) -> list[Forecast] | None:
"""Return the forecast_hourly."""
return [
{
ATTR_FORECAST_NATIVE_TEMP: self.native_temperature,
ATTR_FORECAST_NATIVE_APPARENT_TEMP: self.native_apparent_temperature,
ATTR_FORECAST_NATIVE_TEMP_LOW: self.native_temperature,
ATTR_FORECAST_NATIVE_DEW_POINT: self.native_dew_point,
ATTR_FORECAST_CLOUD_COVERAGE: self.cloud_coverage,
ATTR_FORECAST_NATIVE_PRESSURE: self.native_pressure,
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: self.native_wind_gust_speed,
ATTR_FORECAST_NATIVE_WIND_SPEED: self.native_wind_speed,
ATTR_FORECAST_WIND_BEARING: self.wind_bearing,
ATTR_FORECAST_UV_INDEX: self.uv_index,
ATTR_FORECAST_NATIVE_PRECIPITATION: self._values.get(
"native_precipitation"
),
ATTR_FORECAST_HUMIDITY: self.humidity,
}
]

View File

@@ -0,0 +1 @@
"""Provide a mock integration."""

View File

@@ -0,0 +1,4 @@
{
"domain": "test_bad_version",
"version": "bad"
}

View File

@@ -0,0 +1,4 @@
{
"domain": "test_blocked_version",
"version": "1.0.0"
}

View File

@@ -0,0 +1,9 @@
"""Test deprecated constants custom integration."""
from types import ModuleType
from typing import Any
def import_deprecated_constant(module: ModuleType, constant_name: str) -> Any:
"""Import and return deprecated constant."""
return getattr(module, constant_name)

View File

@@ -0,0 +1,11 @@
"""Component with embedded platforms."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "test_embedded"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock config."""
return True

View File

@@ -0,0 +1,12 @@
{
"entity": {
"switch": {
"something": {
"state": {
"away": "mdi:home-outline",
"home": "mdi:home"
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"domain": "test_embedded",
"name": "Test Embedded",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"version": "1.2.3"
}

View File

@@ -0,0 +1,14 @@
"""Switch platform for the embedded component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Find and return test switches."""

View File

@@ -0,0 +1,15 @@
"""An integration which calls helpers.frame.get_integration_frame."""
import logging
from homeassistant.helpers import frame
def call_get_integration_logger(fallback_name: str) -> logging.Logger:
"""Call get_integration_logger."""
return frame.get_integration_logger(fallback_name)
def call_get_integration_frame() -> frame.IntegrationFrame:
"""Call get_integration_frame."""
return frame.get_integration_frame()

View File

@@ -0,0 +1,9 @@
{
"domain": "test_integration_frame",
"name": "Test Integration Frame",
"documentation": "http://example.com",
"requirements": [],
"dependencies": [],
"codeowners": [],
"version": "1.2.3"
}

View File

@@ -0,0 +1,13 @@
"""Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
DOMAIN = "test_integration_platform"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True

View File

@@ -0,0 +1,7 @@
"""Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True

View File

@@ -0,0 +1,3 @@
"""Constants for test_package custom component."""
TEST = 5

View File

@@ -0,0 +1,3 @@
"""Group."""
MAGIC = 1

View File

@@ -0,0 +1,11 @@
{
"domain": "test_integration_platform",
"name": "Test Integration Platform",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"config_flow": true,
"import_executor": true,
"version": "1.2.3"
}

View File

@@ -0,0 +1 @@
"""Provide a mock package component."""

View File

@@ -0,0 +1,7 @@
{
"domain": "test_legacy_state_translations",
"name": "Test package for legacy state translations",
"documentation": "http://test-package.io",
"config_flow": true,
"version": "1.2.3"
}

View File

@@ -0,0 +1 @@
"""Provide a mock package component."""

View File

@@ -0,0 +1,7 @@
{
"domain": "test_legacy_state_translations_bad_data",
"name": "Test package for legacy state translations",
"documentation": "http://test-package.io",
"config_flow": true,
"version": "1.2.3"
}

View File

@@ -0,0 +1 @@
"""Provide a mock integration."""

View File

@@ -0,0 +1,3 @@
{
"domain": "test_no_version"
}

View File

@@ -0,0 +1,13 @@
"""Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
DOMAIN = "test_package"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True

View File

@@ -0,0 +1,3 @@
"""Constants for test_package custom component."""
TEST = 5

View File

@@ -0,0 +1,15 @@
{
"entity": {
"switch": {
"something": {
"state": {
"away": "mdi:home-outline",
"home": "mdi:home"
}
}
}
},
"services": {
"enable_god_mode": "mdi:shield"
}
}

View File

@@ -0,0 +1,9 @@
{
"domain": "test_package",
"name": "Test Package",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"version": "1.2.3"
}

View File

@@ -0,0 +1,13 @@
"""Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
DOMAIN = "test_package"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True

View File

@@ -0,0 +1 @@
"""Provide a mock button platform."""

View File

@@ -0,0 +1,7 @@
"""Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True

View File

@@ -0,0 +1,3 @@
"""Constants for test_package custom component."""
TEST = 5

View File

@@ -0,0 +1,15 @@
{
"entity": {
"switch": {
"something": {
"state": {
"away": "mdi:home-outline",
"home": "mdi:home"
}
}
}
},
"services": {
"enable_god_mode": "mdi:shield"
}
}

View File

@@ -0,0 +1 @@
"""Provide a mock light platform."""

View File

@@ -0,0 +1,11 @@
{
"domain": "test_package_loaded_executor",
"name": "Test Package that loads in the executor",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"config_flow": true,
"import_executor": true,
"version": "1.2.3"
}

View File

@@ -0,0 +1 @@
"""Provide a mock switch platform."""

View File

@@ -0,0 +1,11 @@
"""Provide a mock package component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import TEST # noqa: F401
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True

View File

@@ -0,0 +1,7 @@
"""Config flow."""
from homeassistant.core import HomeAssistant
async def _async_has_devices(hass: HomeAssistant) -> bool:
return True

View File

@@ -0,0 +1,3 @@
"""Constants for test_package custom component."""
TEST = 5

View File

@@ -0,0 +1,11 @@
{
"domain": "test_package_loaded_loop",
"name": "Test Package that loads in the loop",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"config_flow": true,
"import_executor": false,
"version": "1.2.3"
}

View File

@@ -0,0 +1,12 @@
"""Provide a mock package component."""
import asyncio
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
asyncio.current_task().cancel()
await asyncio.sleep(0)

View File

@@ -0,0 +1,10 @@
{
"domain": "test_package_raises_cancelled_error",
"name": "Test Package that raises asyncio.CancelledError",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"config_flow": false,
"version": "1.2.3"
}

View File

@@ -0,0 +1,18 @@
"""Provide a mock package component."""
import asyncio
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Mock an unsuccessful entry setup."""
asyncio.current_task().cancel()
await asyncio.sleep(0)

View File

@@ -0,0 +1,15 @@
"""Config flow."""
from homeassistant.config_entries import ConfigFlow
from homeassistant.core import HomeAssistant
class MockConfigFlow(
ConfigFlow, domain="test_package_raises_cancelled_error_config_entry"
):
"""Mock config flow."""
async def _async_has_devices(hass: HomeAssistant) -> bool:
"""Return if there are devices that can be discovered."""
return True

View File

@@ -0,0 +1,10 @@
{
"domain": "test_package_raises_cancelled_error_config_entry",
"name": "Test Package that raises asyncio.CancelledError in async_setup_entry",
"documentation": "http://test-package.io",
"requirements": [],
"dependencies": [],
"codeowners": [],
"config_flow": true,
"version": "1.2.3"
}

View File

@@ -0,0 +1,11 @@
"""Provide a mock standalone component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "test_standalone"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Mock a successful setup."""
return True

View File

@@ -0,0 +1 @@
"""Provide a mock integration."""

View File

@@ -0,0 +1,4 @@
{
"domain": "test_with_services",
"version": "1.0"
}