Cleanup ServiceInfo compatibility (#60540)

Co-authored-by: epenet <epenet@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
epenet 2022-05-09 14:17:48 +02:00 committed by GitHub
parent ddd22398f2
commit 141688e210
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1 additions and 412 deletions

View file

@ -52,14 +52,11 @@ from homeassistant.helpers.event import (
async_track_state_added_domain,
async_track_time_interval,
)
from homeassistant.helpers.frame import report
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import DHCPMatcher, async_get_dhcp
from homeassistant.util.async_ import run_callback_threadsafe
from homeassistant.util.network import is_invalid, is_link_local, is_loopback
from .const import DOMAIN
if TYPE_CHECKING:
from scapy.packet import Packet
from scapy.sendrecv import AsyncSniffer
@ -86,36 +83,6 @@ class DhcpServiceInfo(BaseServiceInfo):
hostname: str
macaddress: str
def __getitem__(self, name: str) -> Any:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info['{name}'] instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
return getattr(self, name)
def get(self, name: str, default: Any = None) -> Any:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info.get('{name}') instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
if hasattr(self, name):
return getattr(self, name)
return default
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the dhcp component."""

View file

@ -54,7 +54,6 @@ from homeassistant.helpers import config_validation as cv, event, template
from homeassistant.helpers.device_registry import DeviceEntry
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.frame import report
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
@ -419,20 +418,6 @@ class MqttServiceInfo(BaseServiceInfo):
subscribed_topic: str
timestamp: dt.datetime
def __getitem__(self, name: str) -> Any:
"""
Allow property access by name for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info['{name}'] instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
return getattr(self, name)
def publish(
hass: HomeAssistant,

View file

@ -25,7 +25,6 @@ from homeassistant.data_entry_flow import BaseServiceInfo
from homeassistant.helpers import discovery_flow
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.frame import report
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_ssdp, bind_hass
@ -111,63 +110,6 @@ class SsdpServiceInfo(
):
"""Prepared info from ssdp/upnp entries."""
def __getitem__(self, name: str) -> Any:
"""
Allow property access by name for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info['{name}'] instead of discovery_info.{name}, "
f"discovery_info.upnp['{name}'] "
f"or discovery_info.ssdp_headers['{name}']; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
# Use a property if it is available, fallback to upnp data
if hasattr(self, name):
return getattr(self, name)
if name in self.ssdp_headers and name not in self.upnp:
return self.ssdp_headers.get(name)
return self.upnp[name]
def get(self, name: str, default: Any = None) -> Any:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info.get('{name}') instead of discovery_info.{name}, "
f"discovery_info.upnp.get('{name}') "
f"or discovery_info.ssdp_headers.get('{name}'); "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
if hasattr(self, name):
return getattr(self, name)
return self.upnp.get(name, self.ssdp_headers.get(name, default))
def __contains__(self, name: str) -> bool:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info.__contains__('{name}') "
f"instead of discovery_info.upnp.__contains__('{name}') "
f"or discovery_info.ssdp_headers.__contains__('{name}'); "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
if hasattr(self, name):
return getattr(self, name) is not None
return name in self.upnp or name in self.ssdp_headers
SsdpChange = Enum("SsdpChange", "ALIVE BYEBYE UPDATE")
SsdpCallback = Callable[[SsdpServiceInfo, SsdpChange], Awaitable]

View file

@ -6,7 +6,7 @@ import fnmatch
import logging
import os
import sys
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
from serial.tools.list_ports import comports
from serial.tools.list_ports_common import ListPortInfo
@ -20,7 +20,6 @@ from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.data_entry_flow import BaseServiceInfo
from homeassistant.helpers import discovery_flow, system_info
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.frame import report
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_usb
@ -47,20 +46,6 @@ class UsbServiceInfo(BaseServiceInfo):
manufacturer: str | None
description: str | None
def __getitem__(self, name: str) -> Any:
"""
Allow property access by name for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info['{name}'] instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
return getattr(self, name)
def human_readable_device_name(
device: str,

View file

@ -30,7 +30,6 @@ from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.data_entry_flow import BaseServiceInfo
from homeassistant.helpers import discovery_flow
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.frame import report
from homeassistant.helpers.network import NoURLAvailableError, get_url
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import (
@ -108,36 +107,6 @@ class ZeroconfServiceInfo(BaseServiceInfo):
name: str
properties: dict[str, Any]
def __getitem__(self, name: str) -> Any:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info['{name}'] instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
return getattr(self, name)
def get(self, name: str, default: Any = None) -> Any:
"""
Enable method for compatibility reason.
Deprecated, and will be removed in version 2022.6.
"""
report(
f"accessed discovery_info.get('{name}') instead of discovery_info.{name}; "
"this will fail in version 2022.6",
exclude_integrations={DOMAIN},
error_if_core=False,
)
if hasattr(self, name):
return getattr(self, name)
return default
@bind_hass
async def async_get_instance(hass: HomeAssistant) -> HaZeroconf:

View file

@ -3,7 +3,6 @@ import datetime
import threading
from unittest.mock import MagicMock, patch
import pytest
from scapy import arch # pylint: disable=unused-import # noqa: F401
from scapy.error import Scapy_Exception
from scapy.layers.dhcp import DHCP
@ -973,27 +972,3 @@ async def test_aiodiscover_finds_new_hosts_after_interval(hass):
hostname="connect",
macaddress="b8b7f16db533",
)
@pytest.mark.usefixtures("mock_integration_frame")
async def test_service_info_compatibility(hass, caplog):
"""Test compatibility with old-style dict.
To be removed in 2022.6
"""
discovery_info = dhcp.DhcpServiceInfo(
ip="192.168.210.56",
hostname="connect",
macaddress="b8b7f16db533",
)
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info["ip"] == "192.168.210.56"
assert "Detected integration that accessed discovery_info['ip']" in caplog.text
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info.get("ip") == "192.168.210.56"
assert "Detected integration that accessed discovery_info.get('ip')" in caplog.text
assert discovery_info.get("ip", "fallback_host") == "192.168.210.56"
assert discovery_info.get("invalid_key", "fallback_host") == "fallback_host"

View file

@ -2380,26 +2380,6 @@ async def test_publish_json_from_template(hass, mqtt_mock):
assert mqtt_mock.async_publish.call_args[0][1] == test_str
@pytest.mark.usefixtures("mock_integration_frame")
async def test_service_info_compatibility(hass, caplog):
"""Test compatibility with old-style dict.
To be removed in 2022.6
"""
discovery_info = mqtt.MqttServiceInfo(
topic="tasmota/discovery/DC4F220848A2/config",
payload="",
qos=0,
retain=False,
subscribed_topic="tasmota/discovery/#",
timestamp=None,
)
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info["topic"] == "tasmota/discovery/DC4F220848A2/config"
assert "Detected integration that accessed discovery_info['topic']" in caplog.text
async def test_subscribe_connection_status(hass, mqtt_mock, mqtt_client_mock):
"""Test connextion status subscription."""
mqtt_connected_calls = []

View file

@ -75,17 +75,6 @@ async def test_ssdp_flow_dispatched_on_st(mock_get_ssdp, hass, caplog, mock_flow
assert mock_call_data.x_homeassistant_matching_domains == {"mock-domain"}
assert mock_call_data.upnp == {ssdp.ATTR_UPNP_UDN: "uuid:mock-udn"}
assert "Failed to fetch ssdp data" not in caplog.text
# Compatibility with old dict access (to be removed after 2022.6)
assert mock_call_data[ssdp.ATTR_SSDP_ST] == "mock-st"
assert mock_call_data[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert mock_call_data[ssdp.ATTR_SSDP_USN] == "uuid:mock-udn::mock-st"
assert mock_call_data[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert mock_call_data[ssdp.ATTR_SSDP_EXT] == ""
assert mock_call_data[ssdp.ATTR_UPNP_UDN] == "uuid:mock-udn"
assert mock_call_data[ssdp.ATTR_SSDP_UDN] == ANY
assert mock_call_data["_timestamp"] == ANY
assert mock_call_data[ssdp.ATTR_HA_MATCHING_DOMAINS] == {"mock-domain"}
# End compatibility checks
@patch(
@ -129,17 +118,6 @@ async def test_ssdp_flow_dispatched_on_manufacturer_url(
assert mock_call_data.x_homeassistant_matching_domains == {"mock-domain"}
assert mock_call_data.upnp == {ssdp.ATTR_UPNP_UDN: "uuid:mock-udn"}
assert "Failed to fetch ssdp data" not in caplog.text
# Compatibility with old dict access (to be removed after 2022.6)
assert mock_call_data[ssdp.ATTR_SSDP_ST] == "mock-st"
assert mock_call_data[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert mock_call_data[ssdp.ATTR_SSDP_USN] == "uuid:mock-udn::mock-st"
assert mock_call_data[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert mock_call_data[ssdp.ATTR_SSDP_EXT] == ""
assert mock_call_data[ssdp.ATTR_UPNP_UDN] == "uuid:mock-udn"
assert mock_call_data[ssdp.ATTR_SSDP_UDN] == ANY
assert mock_call_data["_timestamp"] == ANY
assert mock_call_data[ssdp.ATTR_HA_MATCHING_DOMAINS] == {"mock-domain"}
# End compatibility checks
@pytest.mark.usefixtures("mock_get_source_ip")
@ -426,18 +404,6 @@ async def test_discovery_from_advertisement_sets_ssdp_st(
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
ssdp.ATTR_UPNP_UDN: "uuid:mock-udn",
}
# Compatibility with old dict access (to be removed after 2022.6)
assert discovery_info[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert discovery_info[ssdp.ATTR_SSDP_NT] == "mock-st"
# Set by ssdp component, not in original advertisement.
assert discovery_info[ssdp.ATTR_SSDP_ST] == "mock-st"
assert discovery_info[ssdp.ATTR_SSDP_USN] == "uuid:mock-udn::mock-st"
assert discovery_info[ssdp.ATTR_UPNP_UDN] == "uuid:mock-udn"
assert discovery_info[ssdp.ATTR_UPNP_DEVICE_TYPE] == "Paulus"
assert discovery_info[ssdp.ATTR_SSDP_UDN] == ANY
assert discovery_info["nts"] == "ssdp:alive"
assert discovery_info["_timestamp"] == ANY
# End compatibility checks
@patch(
@ -547,25 +513,6 @@ async def test_scan_with_registered_callback(
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
}
# Compatibility with old dict access (to be removed after 2022.6)
assert mock_call_data[ssdp.ATTR_UPNP_DEVICE_TYPE] == "Paulus"
assert mock_call_data[ssdp.ATTR_SSDP_EXT] == ""
assert mock_call_data[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert mock_call_data[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert mock_call_data[ssdp.ATTR_SSDP_ST] == "mock-st"
assert (
mock_call_data[ssdp.ATTR_SSDP_USN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::mock-st"
)
assert (
mock_call_data[ssdp.ATTR_UPNP_UDN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL"
)
assert mock_call_data["x-rincon-bootseq"] == "55"
assert mock_call_data[ssdp.ATTR_SSDP_UDN] == ANY
assert mock_call_data["_timestamp"] == ANY
assert mock_call_data[ssdp.ATTR_HA_MATCHING_DOMAINS] == set()
# End of compatibility checks
assert "Failed to callback info" in caplog.text
async_integration_callback_from_cache = AsyncMock()
@ -622,23 +569,6 @@ async def test_getting_existing_headers(
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
}
# Compatibility with old dict access (to be removed after 2022.6)
assert discovery_info_by_st[ssdp.ATTR_SSDP_EXT] == ""
assert discovery_info_by_st[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert discovery_info_by_st[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert discovery_info_by_st[ssdp.ATTR_SSDP_ST] == "mock-st"
assert (
discovery_info_by_st[ssdp.ATTR_SSDP_USN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::urn:mdx-netflix-com:service:target:3"
)
assert (
discovery_info_by_st[ssdp.ATTR_UPNP_UDN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL"
)
assert discovery_info_by_st[ssdp.ATTR_UPNP_DEVICE_TYPE] == "Paulus"
assert discovery_info_by_st[ssdp.ATTR_SSDP_UDN] == ANY
assert discovery_info_by_st["_timestamp"] == ANY
# End of compatibility checks
discovery_info_by_udn = await ssdp.async_get_discovery_info_by_udn(
hass, "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL"
@ -658,23 +588,6 @@ async def test_getting_existing_headers(
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
}
# Compatibility with old dict access (to be removed after 2022.6)
assert discovery_info_by_udn[ssdp.ATTR_SSDP_EXT] == ""
assert discovery_info_by_udn[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert discovery_info_by_udn[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert discovery_info_by_udn[ssdp.ATTR_SSDP_ST] == "mock-st"
assert (
discovery_info_by_udn[ssdp.ATTR_SSDP_USN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::urn:mdx-netflix-com:service:target:3"
)
assert (
discovery_info_by_udn[ssdp.ATTR_UPNP_UDN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL"
)
assert discovery_info_by_udn[ssdp.ATTR_UPNP_DEVICE_TYPE] == "Paulus"
assert discovery_info_by_udn[ssdp.ATTR_SSDP_UDN] == ANY
assert discovery_info_by_udn["_timestamp"] == ANY
# End of compatibility checks
discovery_info_by_udn_st = await ssdp.async_get_discovery_info_by_udn_st(
hass, "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL", "mock-st"
@ -693,23 +606,6 @@ async def test_getting_existing_headers(
ssdp.ATTR_UPNP_DEVICE_TYPE: "Paulus",
ssdp.ATTR_UPNP_UDN: "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
}
# Compatibility with old dict access (to be removed after 2022.6)
assert discovery_info_by_udn_st[ssdp.ATTR_SSDP_EXT] == ""
assert discovery_info_by_udn_st[ssdp.ATTR_SSDP_LOCATION] == "http://1.1.1.1"
assert discovery_info_by_udn_st[ssdp.ATTR_SSDP_SERVER] == "mock-server"
assert discovery_info_by_udn_st[ssdp.ATTR_SSDP_ST] == "mock-st"
assert (
discovery_info_by_udn_st[ssdp.ATTR_SSDP_USN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::urn:mdx-netflix-com:service:target:3"
)
assert (
discovery_info_by_udn_st[ssdp.ATTR_UPNP_UDN]
== "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL"
)
assert discovery_info_by_udn_st[ssdp.ATTR_UPNP_DEVICE_TYPE] == "Paulus"
assert discovery_info_by_udn_st[ssdp.ATTR_SSDP_UDN] == ANY
assert discovery_info_by_udn_st["_timestamp"] == ANY
# End of compatibility checks
assert (
await ssdp.async_get_discovery_info_by_udn_st(hass, "wrong", "mock-st") is None
@ -845,61 +741,3 @@ async def test_ipv4_does_additional_search_for_sonos(
),
)
assert ssdp_listener.async_search.call_args[1] == {}
@pytest.mark.usefixtures("mock_integration_frame")
async def test_service_info_compatibility(hass, caplog):
"""Test compatibility with old-style dict.
To be removed in 2022.6
"""
discovery_info = ssdp.SsdpServiceInfo(
ssdp_st="mock-st",
ssdp_location="http://1.1.1.1",
ssdp_usn="uuid:mock-udn::mock-st",
ssdp_server="mock-server",
ssdp_ext="",
ssdp_headers=_ssdp_headers(
{
"st": "mock-st",
"location": "http://1.1.1.1",
"usn": "uuid:mock-udn::mock-st",
"server": "mock-server",
"ext": "",
}
),
upnp={ssdp.ATTR_UPNP_DEVICE_TYPE: "ABC"},
)
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info["ssdp_st"] == "mock-st"
assert "Detected integration that accessed discovery_info['ssdp_st']" in caplog.text
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info.get("ssdp_location") == "http://1.1.1.1"
assert (
"Detected integration that accessed discovery_info.get('ssdp_location')"
in caplog.text
)
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert "ssdp_usn" in discovery_info
assert (
"Detected integration that accessed discovery_info.__contains__('ssdp_usn')"
in caplog.text
)
# Root item
assert discovery_info["ssdp_usn"] == "uuid:mock-udn::mock-st"
assert discovery_info.get("ssdp_usn") == "uuid:mock-udn::mock-st"
assert "ssdp_usn" in discovery_info
# SSDP header
assert discovery_info["st"] == "mock-st"
assert discovery_info.get("st") == "mock-st"
assert "st" in discovery_info
# UPnP item
assert discovery_info[ssdp.ATTR_UPNP_DEVICE_TYPE] == "ABC"
assert discovery_info.get(ssdp.ATTR_UPNP_DEVICE_TYPE) == "ABC"
assert ssdp.ATTR_UPNP_DEVICE_TYPE in discovery_info

View file

@ -833,24 +833,3 @@ def test_human_readable_device_name():
assert "Silicon Labs" in name
assert "10C4" in name
assert "8A2A" in name
@pytest.mark.usefixtures("mock_integration_frame")
async def test_service_info_compatibility(hass, caplog):
"""Test compatibility with old-style dict.
To be removed in 2022.6
"""
discovery_info = usb.UsbServiceInfo(
device=slae_sh_device.device,
vid=12345,
pid=12345,
serial_number=slae_sh_device.serial_number,
manufacturer=slae_sh_device.manufacturer,
description=slae_sh_device.description,
)
# Ensure first call get logged
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info["vid"] == 12345
assert "Detected integration that accessed discovery_info['vid']" in caplog.text

View file

@ -3,7 +3,6 @@ from ipaddress import ip_address
from typing import Any
from unittest.mock import call, patch
import pytest
from zeroconf import InterfaceChoice, IPVersion, ServiceStateChange
from zeroconf.asyncio import AsyncServiceInfo
@ -1116,33 +1115,3 @@ async def test_no_name(hass, mock_async_zeroconf):
register_call = mock_async_zeroconf.async_register_service.mock_calls[-1]
info = register_call.args[0]
assert info.name == "Home._home-assistant._tcp.local."
@pytest.mark.usefixtures("mock_integration_frame")
async def test_service_info_compatibility(hass, caplog):
"""Test compatibility with old-style dict.
To be removed in 2022.6
"""
discovery_info = zeroconf.ZeroconfServiceInfo(
host="mock_host",
addresses=["mock_host"],
port=None,
hostname="mock_hostname",
type="mock_type",
name="mock_name",
properties={},
)
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info["host"] == "mock_host"
assert "Detected integration that accessed discovery_info['host']" in caplog.text
with patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set()):
assert discovery_info.get("host") == "mock_host"
assert (
"Detected integration that accessed discovery_info.get('host')" in caplog.text
)
assert discovery_info.get("host", "fallback_host") == "mock_host"
assert discovery_info.get("invalid_key", "fallback_host") == "fallback_host"