1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Handle Modalias missing from the bluetooth adapter details on older BlueZ (#78715)

This commit is contained in:
J. Nick Koston
2022-09-18 20:09:45 -05:00
committed by GitHub
parent 1f92804211
commit 9655f30146
4 changed files with 73 additions and 2 deletions

View File

@@ -116,6 +116,53 @@ async def test_setup_and_stop_passive(hass, mock_bleak_scanner_start, one_adapte
}
async def test_setup_and_stop_old_bluez(
hass, mock_bleak_scanner_start, one_adapter_old_bluez
):
"""Test we and setup and stop the scanner the passive scanner with older bluez."""
entry = MockConfigEntry(
domain=bluetooth.DOMAIN,
data={},
options={},
unique_id="00:00:00:00:00:01",
)
entry.add_to_hass(hass)
init_kwargs = None
class MockBleakScanner:
def __init__(self, *args, **kwargs):
"""Init the scanner."""
nonlocal init_kwargs
init_kwargs = kwargs
async def start(self, *args, **kwargs):
"""Start the scanner."""
async def stop(self, *args, **kwargs):
"""Stop the scanner."""
def register_detection_callback(self, *args, **kwargs):
"""Register a callback."""
with patch(
"homeassistant.components.bluetooth.scanner.OriginalBleakScanner",
MockBleakScanner,
):
assert await async_setup_component(
hass, bluetooth.DOMAIN, {bluetooth.DOMAIN: {}}
)
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
await hass.async_block_till_done()
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
assert init_kwargs == {
"adapter": "hci0",
"scanning_mode": "active",
}
async def test_setup_and_stop_no_bluetooth(hass, caplog, macos_adapter):
"""Test we fail gracefully when bluetooth is not available."""
mock_bt = [