Update m* tests to use entity & device registry fixtures (#103980)

This commit is contained in:
Jan-Philipp Benecke 2023-11-15 10:33:11 +01:00 committed by GitHub
parent 51c1ea85f3
commit 9326ea09a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 361 additions and 298 deletions

View file

@ -63,12 +63,13 @@ WEB_HOOK_FILE_STORED_QUERY_STRING = (
)
async def test_setup_camera_without_webhook(hass: HomeAssistant) -> None:
async def test_setup_camera_without_webhook(
hass: HomeAssistant, device_registry: dr.DeviceRegistry
) -> None:
"""Test a camera with no webhook."""
client = create_mock_motioneye_client()
config_entry = await setup_mock_motioneye_config_entry(hass, client=client)
device_registry = dr.async_get(hass)
device = device_registry.async_get_device(
identifiers={TEST_CAMERA_DEVICE_IDENTIFIER}
)
@ -95,6 +96,7 @@ async def test_setup_camera_without_webhook(hass: HomeAssistant) -> None:
async def test_setup_camera_with_wrong_webhook(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test camera with wrong web hook."""
wrong_url = "http://wrong-url"
@ -123,7 +125,6 @@ async def test_setup_camera_with_wrong_webhook(
)
await hass.async_block_till_done()
device_registry = dr.async_get(hass)
device = device_registry.async_get_device(
identifiers={TEST_CAMERA_DEVICE_IDENTIFIER}
)
@ -151,6 +152,7 @@ async def test_setup_camera_with_wrong_webhook(
async def test_setup_camera_with_old_webhook(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
) -> None:
"""Verify that webhooks are overwritten if they are from this integration.
@ -176,7 +178,6 @@ async def test_setup_camera_with_old_webhook(
)
assert client.async_set_camera.called
device_registry = dr.async_get(hass)
device = device_registry.async_get_device(
identifiers={TEST_CAMERA_DEVICE_IDENTIFIER}
)
@ -204,6 +205,7 @@ async def test_setup_camera_with_old_webhook(
async def test_setup_camera_with_correct_webhook(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
) -> None:
"""Verify that webhooks are not overwritten if they are already correct."""
@ -212,7 +214,6 @@ async def test_setup_camera_with_correct_webhook(
hass, data={CONF_URL: TEST_URL, CONF_WEBHOOK_ID: "webhook_secret_id"}
)
device_registry = dr.async_get(hass)
device = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={TEST_CAMERA_DEVICE_IDENTIFIER},
@ -278,12 +279,13 @@ async def test_setup_camera_with_no_home_assistant_urls(
async def test_good_query(
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
hass_client_no_auth: ClientSessionGenerator,
) -> None:
"""Test good callbacks."""
await async_setup_component(hass, "http", {"http": {}})
device_registry = dr.async_get(hass)
client = create_mock_motioneye_client()
config_entry = await setup_mock_motioneye_config_entry(hass, client=client)
@ -377,12 +379,13 @@ async def test_bad_query_cannot_decode(
async def test_event_media_data(
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
hass_client_no_auth: ClientSessionGenerator,
) -> None:
"""Test an event with a file path generates media data."""
await async_setup_component(hass, "http", {"http": {}})
device_registry = dr.async_get(hass)
client = create_mock_motioneye_client()
config_entry = await setup_mock_motioneye_config_entry(hass, client=client)