mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add type hints to integration tests (part 6) (#87979)
This commit is contained in:
@@ -18,7 +18,7 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
MOCK_IP = "192.168.0.1"
|
||||
@@ -114,7 +114,7 @@ def mock_open_file():
|
||||
yield _mock_open
|
||||
|
||||
|
||||
def test_check_box_health(caplog):
|
||||
def test_check_box_health(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test check box health."""
|
||||
with requests_mock.Mocker() as mock_req:
|
||||
url = f"http://{MOCK_IP}:{MOCK_PORT}/healthz"
|
||||
@@ -151,14 +151,14 @@ def test_valid_file_path() -> None:
|
||||
assert not fb.valid_file_path("test_path")
|
||||
|
||||
|
||||
async def test_setup_platform(hass, mock_healthybox):
|
||||
async def test_setup_platform(hass: HomeAssistant, mock_healthybox) -> None:
|
||||
"""Set up platform with one entity."""
|
||||
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(VALID_ENTITY_ID)
|
||||
|
||||
|
||||
async def test_setup_platform_with_auth(hass, mock_healthybox):
|
||||
async def test_setup_platform_with_auth(hass: HomeAssistant, mock_healthybox) -> None:
|
||||
"""Set up platform with one entity and auth."""
|
||||
valid_config_auth = VALID_CONFIG.copy()
|
||||
valid_config_auth[ip.DOMAIN][CONF_USERNAME] = MOCK_USERNAME
|
||||
@@ -169,7 +169,7 @@ async def test_setup_platform_with_auth(hass, mock_healthybox):
|
||||
assert hass.states.get(VALID_ENTITY_ID)
|
||||
|
||||
|
||||
async def test_process_image(hass, mock_healthybox, mock_image):
|
||||
async def test_process_image(hass: HomeAssistant, mock_healthybox, mock_image) -> None:
|
||||
"""Test successful processing of an image."""
|
||||
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
@@ -213,7 +213,9 @@ async def test_process_image(hass, mock_healthybox, mock_image):
|
||||
)
|
||||
|
||||
|
||||
async def test_process_image_errors(hass, mock_healthybox, mock_image, caplog):
|
||||
async def test_process_image_errors(
|
||||
hass: HomeAssistant, mock_healthybox, mock_image, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test process_image errors."""
|
||||
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
@@ -244,8 +246,13 @@ async def test_process_image_errors(hass, mock_healthybox, mock_image, caplog):
|
||||
|
||||
|
||||
async def test_teach_service(
|
||||
hass, mock_healthybox, mock_image, mock_isfile, mock_open_file, caplog
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
mock_healthybox,
|
||||
mock_image,
|
||||
mock_isfile,
|
||||
mock_open_file,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test teaching of facebox."""
|
||||
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
@@ -314,7 +321,7 @@ async def test_teach_service(
|
||||
assert "ConnectionError: Is facebox running?" in caplog.text
|
||||
|
||||
|
||||
async def test_setup_platform_with_name(hass, mock_healthybox):
|
||||
async def test_setup_platform_with_name(hass: HomeAssistant, mock_healthybox) -> None:
|
||||
"""Set up platform with one entity and a name."""
|
||||
named_entity_id = f"image_processing.{MOCK_NAME}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user