mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00

* Relocate Bluetooth manager to habluetooth library * Relocate Bluetooth manager to habluetooth library * Relocate Bluetooth manager to habluetooth library * fixes * fix patching time * fix more tests * fix more tests * split * Bump habluetooth to 0.7.0 changelog: https://github.com/Bluetooth-Devices/habluetooth/compare/v0.6.1...v0.7.0 This is the big change that will move the manager so the HA PR that will follow this will be a bit larger than the rest of them since the manager is connected to everything * fix types * fix types * fix types * fix patch targets * fix flakey logbook tests (will need another PR) * mock shutdown * bump again * value can be a float now * Revert "value can be a float now" This reverts commit b7e7127143bd2947345c7590fc2727aa47e28d88. * float
55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
"""Tests for the Bluetooth integration."""
|
|
from unittest.mock import patch
|
|
|
|
import bleak
|
|
from habluetooth.usage import (
|
|
install_multiple_bleak_catcher,
|
|
uninstall_multiple_bleak_catcher,
|
|
)
|
|
from habluetooth.wrappers import HaBleakClientWrapper, HaBleakScannerWrapper
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from . import generate_ble_device
|
|
|
|
MOCK_BLE_DEVICE = generate_ble_device(
|
|
"00:00:00:00:00:00",
|
|
"any",
|
|
delegate="",
|
|
details={"path": "/dev/hci0/device"},
|
|
rssi=-127,
|
|
)
|
|
|
|
|
|
async def test_multiple_bleak_scanner_instances(hass: HomeAssistant) -> None:
|
|
"""Test creating multiple BleakScanners without an integration."""
|
|
install_multiple_bleak_catcher()
|
|
|
|
instance = bleak.BleakScanner()
|
|
|
|
assert isinstance(instance, HaBleakScannerWrapper)
|
|
|
|
uninstall_multiple_bleak_catcher()
|
|
|
|
with patch("bleak.get_platform_scanner_backend_type"):
|
|
instance = bleak.BleakScanner()
|
|
|
|
assert not isinstance(instance, HaBleakScannerWrapper)
|
|
|
|
|
|
async def test_wrapping_bleak_client(
|
|
hass: HomeAssistant, enable_bluetooth: None
|
|
) -> None:
|
|
"""Test we wrap BleakClient."""
|
|
install_multiple_bleak_catcher()
|
|
|
|
instance = bleak.BleakClient(MOCK_BLE_DEVICE)
|
|
|
|
assert isinstance(instance, HaBleakClientWrapper)
|
|
|
|
uninstall_multiple_bleak_catcher()
|
|
|
|
instance = bleak.BleakClient(MOCK_BLE_DEVICE)
|
|
|
|
assert not isinstance(instance, HaBleakClientWrapper)
|