Blebox typehints in binary sensor tests (#80676)

pull/81035/head
Michał Huryn 2022-10-26 18:20:49 +02:00 committed by GitHub
parent b148cdd64a
commit a1c18b06fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -1,20 +1,21 @@
"""Blebox binary_sensor entities test."""
from unittest.mock import PropertyMock
from unittest.mock import AsyncMock, PropertyMock
import blebox_uniapi
import pytest
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.const import ATTR_DEVICE_CLASS, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from .conftest import async_setup_entity, mock_feature
@pytest.fixture(name="rainsensor")
def airsensor_fixture():
def airsensor_fixture() -> tuple[AsyncMock, str]:
"""Return a default air quality fixture."""
feature = mock_feature(
feature: AsyncMock = mock_feature(
"binary_sensors",
blebox_uniapi.binary_sensor.Rain,
unique_id="BleBox-windRainSensor-ea68e74f4f49-0.rain",
@ -24,10 +25,10 @@ def airsensor_fixture():
product = feature.product
type(product).name = PropertyMock(return_value="My rain sensor")
type(product).model = PropertyMock(return_value="rainSensor")
return (feature, "binary_sensor.windrainsensor_0_rain")
return feature, "binary_sensor.windrainsensor_0_rain"
async def test_init(rainsensor, hass, config):
async def test_init(rainsensor: AsyncMock, hass: HomeAssistant, config: dict):
"""Test binary_sensor initialisation."""
_, entity_id = rainsensor
entry = await async_setup_entity(hass, config, entity_id)