Use remove_device helper in tests (2/2) (#116442)

Use remove_device helper in tests (part 2)
This commit is contained in:
epenet
2024-04-30 12:50:35 +02:00
committed by GitHub
parent d84d2109c2
commit a3942e019b
17 changed files with 79 additions and 347 deletions

View File

@@ -126,17 +126,3 @@ async def enable_all_entities(hass, freezer, config_entry_id, time_till_next_upd
freezer.tick(time_till_next_update)
async_fire_time_changed(hass)
await hass.async_block_till_done()
async def remove_device(ws_client, device_id, config_entry_id):
"""Remove config entry from a device."""
await ws_client.send_json(
{
"id": 5,
"type": "config/device_registry/remove_config_entry",
"config_entry_id": config_entry_id,
"device_id": device_id,
}
)
response = await ws_client.receive_json()
return response["success"]

View File

@@ -12,7 +12,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from . import mock_responses, remove_device, setup_fronius_integration
from . import mock_responses, setup_fronius_integration
from tests.common import async_fire_time_changed
from tests.test_util.aiohttp import AiohttpClientMocker
@@ -159,11 +159,8 @@ async def test_device_remove_devices(
)
inverter_1 = device_registry.async_get_device(identifiers={(DOMAIN, "12345678")})
assert (
await remove_device(
await hass_ws_client(hass), inverter_1.id, config_entry.entry_id
)
is True
)
client = await hass_ws_client(hass)
response = await client.remove_device(inverter_1.id, config_entry.entry_id)
assert response["success"]
assert not device_registry.async_get_device(identifiers={(DOMAIN, "12345678")})