mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Handle empty ssdp descriptions in the cache (#51253)
This commit is contained in:
parent
3ca7eb9440
commit
32dc62a996
@ -42,7 +42,7 @@ class DescriptionManager:
|
||||
@callback
|
||||
def async_cached_description(self, xml_location: str) -> None | dict[str, str]:
|
||||
"""Fetch the description from the cache."""
|
||||
return self._description_cache[xml_location]
|
||||
return self._description_cache.get(xml_location)
|
||||
|
||||
async def _fetch_description(self, xml_location: str) -> None | dict[str, str]:
|
||||
"""Fetch an XML description."""
|
||||
|
@ -189,6 +189,7 @@ async def test_scan_description_fetch_fail(hass, aioclient_mock, exc):
|
||||
aioclient_mock.get("http://1.1.1.1", exc=exc)
|
||||
mock_ssdp_response = {
|
||||
"st": "mock-st",
|
||||
"usn": "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::urn:mdx-netflix-com:service:target:3",
|
||||
"location": "http://1.1.1.1",
|
||||
}
|
||||
mock_get_ssdp = {
|
||||
@ -203,6 +204,15 @@ async def test_scan_description_fetch_fail(hass, aioclient_mock, exc):
|
||||
|
||||
assert not mock_init.mock_calls
|
||||
|
||||
assert ssdp.async_get_discovery_info_by_st(hass, "mock-st") == [
|
||||
{
|
||||
"UDN": "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL",
|
||||
"ssdp_location": "http://1.1.1.1",
|
||||
"ssdp_st": "mock-st",
|
||||
"ssdp_usn": "uuid:TIVRTLSR7ANF-D6E-1557809135086-RETAIL::urn:mdx-netflix-com:service:target:3",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
async def test_scan_description_parse_fail(hass, aioclient_mock):
|
||||
"""Test invalid XML."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user