mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 02:03:27 +01:00
Use hardware/usb domain constant in tests (#162934)
This commit is contained in:
@@ -6,6 +6,9 @@ from unittest.mock import AsyncMock, Mock, call, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.homeassistant_connect_zbt2.const import DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.firmware_config_flow import (
|
||||
STEP_PICK_FIRMWARE_THREAD,
|
||||
STEP_PICK_FIRMWARE_ZIGBEE,
|
||||
@@ -18,7 +21,7 @@ from homeassistant.components.homeassistant_hardware.util import (
|
||||
FirmwareInfo,
|
||||
ResetTarget,
|
||||
)
|
||||
from homeassistant.components.usb import USBDevice
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN, USBDevice
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@@ -442,8 +445,8 @@ async def test_duplicate_discovery_updates_usb_path(hass: HomeAssistant) -> None
|
||||
|
||||
async def test_firmware_callback_auto_creates_entry(hass: HomeAssistant) -> None:
|
||||
"""Test that firmware notification triggers import flow that auto-creates config entry."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "usb"}, data=USB_DATA_ZBT2
|
||||
@@ -499,8 +502,8 @@ async def test_firmware_callback_auto_creates_entry(hass: HomeAssistant) -> None
|
||||
|
||||
async def test_firmware_callback_updates_existing_entry(hass: HomeAssistant) -> None:
|
||||
"""Test that firmware notification updates existing config entry device path."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
# Create existing config entry with old device path
|
||||
config_entry = MockConfigEntry(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Test the Home Assistant Connect ZBT-2 hardware platform."""
|
||||
|
||||
from homeassistant.components.homeassistant_connect_zbt2.const import DOMAIN
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
@@ -24,7 +25,7 @@ async def test_hardware_info(
|
||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, addon_store_info
|
||||
) -> None:
|
||||
"""Test we can get the board info."""
|
||||
assert await async_setup_component(hass, "usb", {})
|
||||
assert await async_setup_component(hass, USB_DOMAIN, {})
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
|
||||
# Setup the config entry
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.homeassistant_connect_zbt2.const import DOMAIN
|
||||
from homeassistant.components.usb import USBDevice
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN, USBDevice
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -65,7 +65,7 @@ async def test_setup_fails_on_missing_usb_port(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.usefixtures("force_usb_polling_watcher")
|
||||
async def test_usb_device_reactivity(hass: HomeAssistant) -> None:
|
||||
"""Test setting up USB monitoring."""
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, USB_DOMAIN, {"usb": {}})
|
||||
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
|
||||
@@ -16,7 +16,10 @@ from ha_silabs_firmware_client import (
|
||||
import pytest
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.components.homeassistant_hardware.const import Z2M_EMBER_DOCS_URL
|
||||
from homeassistant.components.homeassistant_hardware.const import (
|
||||
DOMAIN,
|
||||
Z2M_EMBER_DOCS_URL,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.firmware_config_flow import (
|
||||
STEP_PICK_FIRMWARE_THREAD,
|
||||
STEP_PICK_FIRMWARE_ZIGBEE,
|
||||
@@ -195,7 +198,7 @@ async def mock_test_firmware_platform(
|
||||
mock_integration(hass, mock_module)
|
||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
with mock_config_flow(TEST_DOMAIN, FakeFirmwareConfigFlow):
|
||||
yield
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, Mock, call, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.homeassistant_hardware.const import DATA_COMPONENT
|
||||
from homeassistant.components.homeassistant_hardware.const import DATA_COMPONENT, DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_firmware_update_context,
|
||||
async_is_firmware_update_in_progress,
|
||||
@@ -20,7 +20,7 @@ from homeassistant.components.homeassistant_hardware.util import (
|
||||
ApplicationType,
|
||||
FirmwareInfo,
|
||||
)
|
||||
from homeassistant.components.usb import USBDevice
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN, USBDevice
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
@@ -47,7 +47,7 @@ FIRMWARE_INFO_SPINEL = FirmwareInfo(
|
||||
async def test_dispatcher_registration(hass: HomeAssistant) -> None:
|
||||
"""Test HardwareInfoDispatcher registration."""
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
# Mock provider 1 with a synchronous method to pull firmware info
|
||||
provider1_config_entry = MockConfigEntry(
|
||||
@@ -123,7 +123,7 @@ async def test_dispatcher_iter_error_handling(
|
||||
) -> None:
|
||||
"""Test HardwareInfoDispatcher ignoring errors from firmware info providers."""
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
provider1_config_entry = MockConfigEntry(
|
||||
domain="zha",
|
||||
@@ -163,7 +163,7 @@ async def test_dispatcher_callback_error_handling(
|
||||
) -> None:
|
||||
"""Test HardwareInfoDispatcher ignoring errors from firmware info callbacks."""
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
provider1_config_entry = MockConfigEntry(
|
||||
domain="zha",
|
||||
unique_id="some_unique_id1",
|
||||
@@ -193,7 +193,7 @@ async def test_dispatcher_callback_error_handling(
|
||||
|
||||
async def test_firmware_update_tracking(hass: HomeAssistant) -> None:
|
||||
"""Test firmware update tracking API."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
device_path = "/dev/ttyUSB0"
|
||||
|
||||
@@ -225,7 +225,7 @@ async def test_firmware_update_tracking(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_firmware_update_context_manager(hass: HomeAssistant) -> None:
|
||||
"""Test firmware update progress context manager."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
device_path = "/dev/ttyUSB0"
|
||||
|
||||
@@ -263,7 +263,7 @@ async def test_firmware_update_context_manager(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_dispatcher_callback_self_unregister(hass: HomeAssistant) -> None:
|
||||
"""Test callbacks can unregister themselves during notification."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
called_callbacks = []
|
||||
unregister_funcs = {}
|
||||
@@ -304,8 +304,8 @@ async def test_firmware_callback_no_usb_device(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test firmware notification when usb_device_from_path returns None."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -335,8 +335,8 @@ async def test_firmware_callback_no_hardware_domain(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test firmware notification when no hardware domain is found for device."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
# Create a USB device that doesn't match any hardware integration
|
||||
usb_device = USBDevice(
|
||||
|
||||
@@ -7,6 +7,8 @@ from unittest.mock import Mock, call, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.homeassistant import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware import DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware.coordinator import (
|
||||
FirmwareUpdateCoordinator,
|
||||
)
|
||||
@@ -122,8 +124,8 @@ async def mock_switch_config_entry(
|
||||
mock_firmware_client,
|
||||
) -> AsyncGenerator[ConfigEntry]:
|
||||
"""Set up a mock config entry for testing."""
|
||||
await async_setup_component(hass, "homeassistant", {})
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_DOMAIN, {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
|
||||
@@ -15,6 +15,7 @@ from homeassistant.components.homeassistant import (
|
||||
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||
SERVICE_UPDATE_ENTITY,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware import DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware.coordinator import (
|
||||
FirmwareUpdateCoordinator,
|
||||
)
|
||||
@@ -232,7 +233,7 @@ async def mock_update_config_entry(
|
||||
) -> AsyncGenerator[ConfigEntry]:
|
||||
"""Set up a mock Home Assistant Hardware firmware update entity."""
|
||||
await async_setup_component(hass, HOMEASSISTANT_DOMAIN, {})
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
|
||||
@@ -15,6 +15,7 @@ from homeassistant.components.hassio import (
|
||||
AddonManager,
|
||||
AddonState,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware import DOMAIN
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_register_firmware_info_provider,
|
||||
)
|
||||
@@ -72,7 +73,7 @@ ZHA_CONFIG_ENTRY2 = MockConfigEntry(
|
||||
async def test_guess_firmware_info_unknown(hass: HomeAssistant) -> None:
|
||||
"""Test guessing the firmware type."""
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
assert (await guess_firmware_info(hass, "/dev/missing")) == FirmwareInfo(
|
||||
device="/dev/missing",
|
||||
@@ -86,7 +87,7 @@ async def test_guess_firmware_info_unknown(hass: HomeAssistant) -> None:
|
||||
async def test_guess_firmware_info_integrations(hass: HomeAssistant) -> None:
|
||||
"""Test guessing the firmware via OTBR and ZHA."""
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
# One instance of ZHA and two OTBRs
|
||||
zha = MockConfigEntry(domain="zha", unique_id="some_unique_id_1")
|
||||
@@ -553,7 +554,7 @@ async def test_probe_silabs_firmware_type(
|
||||
|
||||
async def test_async_flash_silabs_firmware(hass: HomeAssistant) -> None:
|
||||
"""Test async_flash_silabs_firmware."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
owner1 = create_mock_owner()
|
||||
owner2 = create_mock_owner()
|
||||
@@ -687,7 +688,7 @@ async def test_async_flash_silabs_firmware_flash_failure(
|
||||
hass: HomeAssistant, side_effect: Exception, expected_error_msg: str
|
||||
) -> None:
|
||||
"""Test async_flash_silabs_firmware flash failure."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
owner1 = create_mock_owner()
|
||||
owner2 = create_mock_owner()
|
||||
@@ -748,7 +749,7 @@ async def test_async_flash_silabs_firmware_flash_failure(
|
||||
|
||||
async def test_async_flash_silabs_firmware_probe_failure(hass: HomeAssistant) -> None:
|
||||
"""Test async_flash_silabs_firmware probe failure."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
owner1 = create_mock_owner()
|
||||
owner2 = create_mock_owner()
|
||||
|
||||
@@ -6,6 +6,9 @@ from unittest.mock import AsyncMock, Mock, call, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.hassio import AddonInfo, AddonState
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.firmware_config_flow import (
|
||||
STEP_PICK_FIRMWARE_THREAD,
|
||||
STEP_PICK_FIRMWARE_ZIGBEE,
|
||||
@@ -23,7 +26,7 @@ from homeassistant.components.homeassistant_hardware.util import (
|
||||
FirmwareInfo,
|
||||
)
|
||||
from homeassistant.components.homeassistant_sky_connect.const import DOMAIN
|
||||
from homeassistant.components.usb import USBDevice
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN, USBDevice
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@@ -446,8 +449,8 @@ async def test_firmware_callback_auto_creates_entry(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test that firmware notification triggers import flow that auto-creates config entry."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "usb"}, data=usb_data
|
||||
@@ -556,8 +559,8 @@ async def test_firmware_callback_updates_existing_entry(
|
||||
usb_data: UsbServiceInfo, model: str, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test that firmware notification updates existing config entry device path."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, "usb", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
await async_setup_component(hass, USB_DOMAIN, {})
|
||||
|
||||
# Create existing config entry with old device path
|
||||
config_entry = MockConfigEntry(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Test the Home Assistant SkyConnect hardware platform."""
|
||||
|
||||
from homeassistant.components.homeassistant_sky_connect.const import DOMAIN
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
@@ -37,7 +38,7 @@ async def test_hardware_info(
|
||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, addon_store_info
|
||||
) -> None:
|
||||
"""Test we can get the board info."""
|
||||
assert await async_setup_component(hass, "usb", {})
|
||||
assert await async_setup_component(hass, USB_DOMAIN, {})
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
|
||||
# Setup the config entry
|
||||
|
||||
@@ -18,7 +18,7 @@ from homeassistant.components.homeassistant_sky_connect.const import (
|
||||
SERIAL_NUMBER,
|
||||
VID,
|
||||
)
|
||||
from homeassistant.components.usb import USBDevice
|
||||
from homeassistant.components.usb import DOMAIN as USB_DOMAIN, USBDevice
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -126,7 +126,7 @@ async def test_setup_fails_on_missing_usb_port(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.usefixtures("force_usb_polling_watcher")
|
||||
async def test_usb_device_reactivity(hass: HomeAssistant) -> None:
|
||||
"""Test setting up USB monitoring."""
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, USB_DOMAIN, {"usb": {}})
|
||||
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
|
||||
@@ -10,6 +10,9 @@ import pytest
|
||||
import python_otbr_api
|
||||
|
||||
from homeassistant.components import otbr
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_register_firmware_info_callback,
|
||||
)
|
||||
@@ -1010,7 +1013,7 @@ async def test_hassio_discovery_reload(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_addon_info
|
||||
) -> None:
|
||||
"""Test the hassio discovery flow."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
aioclient_mock.get(
|
||||
"http://core-openthread-border-router:8081/node/dataset/active", text=""
|
||||
|
||||
@@ -4,6 +4,9 @@ from unittest.mock import AsyncMock, Mock, call, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_register_firmware_info_callback,
|
||||
)
|
||||
@@ -174,7 +177,7 @@ async def test_hardware_firmware_info_provider_notification(
|
||||
)
|
||||
otbr.add_to_hass(hass)
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
callback = Mock()
|
||||
async_register_firmware_info_callback(hass, DEVICE_PATH, callback)
|
||||
|
||||
@@ -10,6 +10,7 @@ import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import usb
|
||||
from homeassistant.components.usb import DOMAIN
|
||||
from homeassistant.components.usb.models import USBDevice
|
||||
from homeassistant.components.usb.utils import scan_serial_ports, usb_device_from_path
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP
|
||||
@@ -84,7 +85,7 @@ async def test_aiousbwatcher_discovery(
|
||||
),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -159,7 +160,7 @@ async def test_polling_discovery(
|
||||
patch_scanned_serial_ports(side_effect=scan_serial_ports) as mock_ports,
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -197,7 +198,7 @@ async def test_removal_by_aiousbwatcher_before_started(hass: HomeAssistant) -> N
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch_scanned_serial_ports(return_value=[]):
|
||||
@@ -233,7 +234,7 @@ async def test_discovered_by_websocket_scan(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -272,7 +273,7 @@ async def test_discovered_by_websocket_scan_limited_by_description_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -312,7 +313,7 @@ async def test_most_targeted_matcher_wins(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -351,7 +352,7 @@ async def test_discovered_by_websocket_scan_rejected_by_description_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -394,7 +395,7 @@ async def test_discovered_by_websocket_scan_limited_by_serial_number_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -433,7 +434,7 @@ async def test_discovered_by_websocket_scan_rejected_by_serial_number_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -476,7 +477,7 @@ async def test_discovered_by_websocket_scan_limited_by_manufacturer_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -520,7 +521,7 @@ async def test_discovered_by_websocket_scan_rejected_by_manufacturer_matcher(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -558,7 +559,7 @@ async def test_discovered_by_websocket_rejected_with_empty_serial_number_only(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -594,7 +595,7 @@ async def test_discovered_by_websocket_scan_match_vid_only(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -631,7 +632,7 @@ async def test_discovered_by_websocket_scan_match_vid_wrong_pid(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -667,7 +668,7 @@ async def test_discovered_by_websocket_no_vid_pid(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -703,7 +704,7 @@ async def test_non_matching_discovered_by_scanner_after_started(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -738,7 +739,7 @@ async def test_aiousbwatcher_on_wsl_fallback_without_throwing_exception(
|
||||
patch_scanned_serial_ports(return_value=mock_ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -785,7 +786,7 @@ async def test_discovered_by_aiousbwatcher_before_started(hass: HomeAssistant) -
|
||||
),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
@@ -897,7 +898,7 @@ async def test_web_socket_triggers_discovery_request_callbacks(
|
||||
patch_scanned_serial_ports(return_value=[]),
|
||||
patch.object(hass.config_entries.flow, "async_init"),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -933,7 +934,7 @@ async def test_initial_scan_callback(
|
||||
patch_scanned_serial_ports(return_value=[]),
|
||||
patch.object(hass.config_entries.flow, "async_init"),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
cancel_1 = usb.async_register_initial_scan_callback(hass, mock_callback_1)
|
||||
assert len(mock_callback_1.mock_calls) == 0
|
||||
|
||||
@@ -968,7 +969,7 @@ async def test_cancel_initial_scan_callback(
|
||||
patch_scanned_serial_ports(return_value=[]),
|
||||
patch.object(hass.config_entries.flow, "async_init"),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
cancel = usb.async_register_initial_scan_callback(hass, mock_callback)
|
||||
assert len(mock_callback.mock_calls) == 0
|
||||
|
||||
@@ -1071,7 +1072,7 @@ async def test_cp2102n_ordering_on_macos(
|
||||
patch_scanned_serial_ports(return_value=ports),
|
||||
patch.object(hass.config_entries.flow, "async_init") as mock_config_flow,
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
@@ -1122,7 +1123,7 @@ async def test_register_port_event_callback(
|
||||
with (
|
||||
patch_scanned_serial_ports(return_value=[]),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
|
||||
_cancel1 = usb.async_register_port_event_callback(hass, mock_callback1)
|
||||
cancel2 = usb.async_register_port_event_callback(hass, mock_callback2)
|
||||
@@ -1217,7 +1218,7 @@ async def test_register_port_event_callback_failure(
|
||||
with (
|
||||
patch_scanned_serial_ports(return_value=[]),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
|
||||
usb.async_register_port_event_callback(hass, mock_callback1)
|
||||
usb.async_register_port_event_callback(hass, mock_callback2)
|
||||
@@ -1490,7 +1491,7 @@ async def test_removal_aborts_discovery_flows(
|
||||
mock_config_flow("test1", TestFlow),
|
||||
mock_config_flow("test2", TestFlow),
|
||||
):
|
||||
assert await async_setup_component(hass, "usb", {"usb": {}})
|
||||
assert await async_setup_component(hass, DOMAIN, {"usb": {}})
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -5,6 +5,9 @@ from unittest.mock import MagicMock, patch
|
||||
import pytest
|
||||
from zigpy.application import ControllerApplication
|
||||
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_register_firmware_info_callback,
|
||||
)
|
||||
@@ -102,7 +105,7 @@ async def test_hardware_firmware_info_provider_notification(
|
||||
"""Test that the ZHA gateway provides hardware and firmware information."""
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
callback = MagicMock()
|
||||
async_register_firmware_info_callback(hass, "/dev/ttyUSB0", callback)
|
||||
|
||||
@@ -13,6 +13,9 @@ from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH
|
||||
from zigpy.device import Device
|
||||
from zigpy.exceptions import TransientConnectionError
|
||||
|
||||
from homeassistant.components.homeassistant_hardware import (
|
||||
DOMAIN as HOMEASSISTANT_HARDWARE_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware.helpers import (
|
||||
async_is_firmware_update_in_progress,
|
||||
async_register_firmware_update_in_progress,
|
||||
@@ -330,7 +333,7 @@ async def test_setup_no_firmware_update_in_progress(
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
) -> None:
|
||||
"""Test that ZHA setup proceeds normally when no firmware update is in progress."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
config_entry.add_to_hass(hass)
|
||||
device_path = config_entry.data[CONF_DEVICE][CONF_DEVICE_PATH]
|
||||
@@ -345,7 +348,7 @@ async def test_setup_firmware_update_in_progress(
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that ZHA setup is blocked when firmware update is in progress."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
config_entry.add_to_hass(hass)
|
||||
device_path = config_entry.data[CONF_DEVICE][CONF_DEVICE_PATH]
|
||||
@@ -362,7 +365,7 @@ async def test_setup_firmware_update_in_progress_prevents_silabs_warning(
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
) -> None:
|
||||
"""Test firmware update in progress prevents silabs firmware warning on setup failure."""
|
||||
await async_setup_component(hass, "homeassistant_hardware", {})
|
||||
await async_setup_component(hass, HOMEASSISTANT_HARDWARE_DOMAIN, {})
|
||||
|
||||
config_entry.add_to_hass(hass)
|
||||
device_path = config_entry.data[CONF_DEVICE][CONF_DEVICE_PATH]
|
||||
|
||||
Reference in New Issue
Block a user