forked from auracaster/bumble_mirror
Fix some typos and annotations
This commit is contained in:
@@ -292,9 +292,9 @@ async def test_legacy_advertising_disconnection(auto_restart):
|
||||
await devices[0].start_advertising(
|
||||
auto_restart=auto_restart, advertising_interval_min=1.0
|
||||
)
|
||||
connecion = await devices[1].connect(devices[0].random_address)
|
||||
connection = await devices[1].connect(devices[0].random_address)
|
||||
|
||||
await connecion.disconnect()
|
||||
await connection.disconnect()
|
||||
|
||||
await async_barrier()
|
||||
await async_barrier()
|
||||
|
||||
@@ -57,15 +57,13 @@ async def test_self_disconnection():
|
||||
await two_devices.setup_connection()
|
||||
await two_devices.connections[0].disconnect()
|
||||
await async_barrier()
|
||||
assert two_devices.connections[0] is None
|
||||
assert two_devices.connections[1] is None
|
||||
assert not two_devices.connections
|
||||
|
||||
two_devices = TwoDevices()
|
||||
await two_devices.setup_connection()
|
||||
await two_devices.connections[1].disconnect()
|
||||
await async_barrier()
|
||||
assert two_devices.connections[0] is None
|
||||
assert two_devices.connections[1] is None
|
||||
assert not two_devices.connections
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -31,10 +31,10 @@ from bumble.transport.common import AsyncPipeSink
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
class Devices:
|
||||
connections: list[Connection | None]
|
||||
connections: dict[int, Connection]
|
||||
|
||||
def __init__(self, num_devices: int) -> None:
|
||||
self.connections = [None for _ in range(num_devices)]
|
||||
self.connections = {}
|
||||
|
||||
self.link = LocalLink()
|
||||
addresses = [":".join([f"F{i}"] * 6) for i in range(num_devices)]
|
||||
@@ -60,12 +60,14 @@ class Devices:
|
||||
asyncio.get_event_loop().create_future() for _ in range(num_devices)
|
||||
]
|
||||
|
||||
def on_connection(self, which, connection):
|
||||
def on_connection(self, which: int, connection: Connection) -> None:
|
||||
self.connections[which] = connection
|
||||
connection.on('disconnection', lambda code: self.on_disconnection(which))
|
||||
connection.on(
|
||||
connection.EVENT_DISCONNECTION, lambda *_: self.on_disconnection(which)
|
||||
)
|
||||
|
||||
def on_disconnection(self, which):
|
||||
self.connections[which] = None
|
||||
def on_disconnection(self, which: int) -> None:
|
||||
self.connections.pop(which, None)
|
||||
|
||||
def on_paired(self, which: int, keys: PairingKeys) -> None:
|
||||
self.paired[which].set_result(keys)
|
||||
|
||||
Reference in New Issue
Block a user