Skip to content

Commit

Permalink
fix: update for bleak 0.20.0 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Mar 18, 2023
1 parent c3ef7b9 commit 78f9a1e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from bleak.backends.scanner import AdvertisementData
from bleak.backends.service import BleakGATTServiceCollection
from bleak.exc import BleakDBusError, BleakDeviceNotFoundError
from bluetooth_adapters.history import load_history_from_managed_objects

import bleak_retry_connector
from bleak_retry_connector import (
Expand Down Expand Up @@ -431,6 +432,7 @@ async def disconnect(self, *args, **kwargs):
"aa:bb:cc:dd:ee:ff",
"name",
{"path": "/org/bluez/hci2/dev_FA_23_9D_AA_45_46"},
-127,
),
"test",
)
Expand Down Expand Up @@ -464,7 +466,9 @@ async def disconnect(self, *args, **kwargs):
try:
await establish_connection(
FakeBleakClient,
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"source": "esphome_proxy_1"}),
BLEDevice(
"aa:bb:cc:dd:ee:ff", "name", {"source": "esphome_proxy_1"}, -127
),
"test",
)
except BleakError as e:
Expand Down Expand Up @@ -505,6 +509,7 @@ async def disconnect(self, *args, **kwargs):
"aa:bb:cc:dd:ee:ff",
"name",
{"path": "/org/bluez/hci2/dev_FA_23_9D_AA_45_46"},
-127,
),
"test",
)
Expand Down Expand Up @@ -592,16 +597,16 @@ async def disconnect(self, *args, **kwargs):
def test_ble_device_has_changed():
"""Test that the BLEDevice has changed when the underlying device has changed."""
assert not ble_device_has_changed(
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}, -127),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}, -127),
)
assert ble_device_has_changed(
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}),
BLEDevice("ab:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}, -127),
BLEDevice("ab:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}, -127),
)
assert ble_device_has_changed(
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/2"}),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/1"}, -127),
BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"path": "/dev/2"}, -127),
)


Expand Down Expand Up @@ -763,6 +768,7 @@ def __init__(self):
"aa:bb:cc:dd:ee:ff",
"name",
{"path": "/org/bluez/hci2/dev_FA_23_9D_AA_45_46"},
-127,
delegate=False,
),
"test",
Expand Down Expand Up @@ -1543,6 +1549,7 @@ async def test_ble_device_description():
"aa:bb:cc:dd:ee:ff",
"name",
{"path": "/org/bluez/hci2/dev_FA_23_9D_AA_45_46"},
-127,
)
assert (
ble_device_description(device) == "aa:bb:cc:dd:ee:ff - name -> /org/bluez/hci2"
Expand All @@ -1551,11 +1558,14 @@ async def test_ble_device_description():
"aa:bb:cc:dd:ee:ff",
"name",
{"path": "/org/bluez/hci2/dev_FA_23_9D_AA_45_46"},
-127,
)
assert (
ble_device_description(device2) == "aa:bb:cc:dd:ee:ff - name -> /org/bluez/hci2"
)
device3 = BLEDevice("aa:bb:cc:dd:ee:ff", "name", {"source": "esphome_proxy_1"})
device3 = BLEDevice(
"aa:bb:cc:dd:ee:ff", "name", {"source": "esphome_proxy_1"}, -127
)
assert (
ble_device_description(device3) == "aa:bb:cc:dd:ee:ff - name -> esphome_proxy_1"
)
Expand Down Expand Up @@ -1627,6 +1637,9 @@ def __init__(self):
bleak_retry_connector.bluez.get_global_bluez_manager = AsyncMock(
return_value=FakeBluezManager()
)
bleak_retry_connector.load_history_from_managed_objects = (
load_history_from_managed_objects
)
bleak_retry_connector.bluez.defs = defs
seen_devices: dict[str, tuple[BLEDevice, AdvertisementData]] = {}

Expand Down

0 comments on commit 78f9a1e

Please sign in to comment.