mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve type hints in comfoconnect tests (#120345)
This commit is contained in:
parent
d073fd9b37
commit
4089b808c3
@ -1,9 +1,9 @@
|
|||||||
"""Tests for the comfoconnect sensor platform."""
|
"""Tests for the comfoconnect sensor platform."""
|
||||||
|
|
||||||
# import json
|
from unittest.mock import MagicMock, patch
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN
|
from homeassistant.components.sensor import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -28,7 +28,7 @@ VALID_CONFIG = {
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_bridge_discover():
|
def mock_bridge_discover() -> Generator[MagicMock]:
|
||||||
"""Mock the bridge discover method."""
|
"""Mock the bridge discover method."""
|
||||||
with patch("pycomfoconnect.bridge.Bridge.discover") as mock_bridge_discover:
|
with patch("pycomfoconnect.bridge.Bridge.discover") as mock_bridge_discover:
|
||||||
mock_bridge_discover.return_value[0].uuid.hex.return_value = "00"
|
mock_bridge_discover.return_value[0].uuid.hex.return_value = "00"
|
||||||
@ -36,7 +36,7 @@ def mock_bridge_discover():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_comfoconnect_command():
|
def mock_comfoconnect_command() -> Generator[MagicMock]:
|
||||||
"""Mock the ComfoConnect connect method."""
|
"""Mock the ComfoConnect connect method."""
|
||||||
with patch(
|
with patch(
|
||||||
"pycomfoconnect.comfoconnect.ComfoConnect._command"
|
"pycomfoconnect.comfoconnect.ComfoConnect._command"
|
||||||
@ -45,14 +45,19 @@ def mock_comfoconnect_command():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def setup_sensor(hass, mock_bridge_discover, mock_comfoconnect_command):
|
async def setup_sensor(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_bridge_discover: MagicMock,
|
||||||
|
mock_comfoconnect_command: MagicMock,
|
||||||
|
) -> None:
|
||||||
"""Set up demo sensor component."""
|
"""Set up demo sensor component."""
|
||||||
with assert_setup_component(1, DOMAIN):
|
with assert_setup_component(1, DOMAIN):
|
||||||
await async_setup_component(hass, DOMAIN, VALID_CONFIG)
|
await async_setup_component(hass, DOMAIN, VALID_CONFIG)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_sensors(hass: HomeAssistant, setup_sensor) -> None:
|
@pytest.mark.usefixtures("setup_sensor")
|
||||||
|
async def test_sensors(hass: HomeAssistant) -> None:
|
||||||
"""Test the sensors."""
|
"""Test the sensors."""
|
||||||
state = hass.states.get("sensor.comfoairq_inside_humidity")
|
state = hass.states.get("sensor.comfoairq_inside_humidity")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user