Add compatibility tests for UsbServiceInfo (#60753)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-01 16:43:31 +01:00 committed by GitHub
parent 7f355681a7
commit 2fe0382841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -777,3 +777,27 @@ def test_human_readable_device_name():
assert "Silicon Labs" in name
assert "10C4" in name
assert "8A2A" in name
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
assert discovery_info["vid"] == 12345
assert "Detected code that accessed discovery_info['vid']" in caplog.text
# Ensure second call doesn't get logged
caplog.clear()
assert discovery_info["vid"] == 12345
assert "Detected code that accessed discovery_info['vid']" not in caplog.text