Fix dhcp None hostname (#67289)

* Fix dhcp None hostname

* Test handle None hostname
This commit is contained in:
Martin Hjelmare 2022-02-26 19:37:24 +01:00 committed by GitHub
parent f901c61d54
commit d9abd5efea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 7 deletions

View file

@ -663,6 +663,28 @@ async def test_device_tracker_registered(hass):
await hass.async_block_till_done()
async def test_device_tracker_registered_hostname_none(hass):
"""Test handle None hostname."""
with patch.object(hass.config_entries.flow, "async_init") as mock_init:
device_tracker_watcher = dhcp.DeviceTrackerRegisteredWatcher(
hass,
{},
[{"domain": "mock-domain", "hostname": "connect", "macaddress": "B8B7F1*"}],
)
await device_tracker_watcher.async_start()
await hass.async_block_till_done()
async_dispatcher_send(
hass,
CONNECTED_DEVICE_REGISTERED,
{"ip": "192.168.210.56", "mac": "b8b7f16db533", "host_name": None},
)
await hass.async_block_till_done()
assert len(mock_init.mock_calls) == 0
await device_tracker_watcher.async_stop()
await hass.async_block_till_done()
async def test_device_tracker_hostname_and_macaddress_after_start(hass):
"""Test matching based on hostname and macaddress after start."""