mirror of
https://github.com/google/bumble.git
synced 2026-04-17 00:35:31 +00:00
RFCOMM: Slightly refactor and correct constants
This commit is contained in:
@@ -15,7 +15,11 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
# Imports
|
||||
# -----------------------------------------------------------------------------
|
||||
from bumble.rfcomm import RFCOMM_Frame
|
||||
import asyncio
|
||||
import pytest
|
||||
|
||||
from . import test_utils
|
||||
from bumble.rfcomm import RFCOMM_Frame, Server, Client, DLC
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -43,6 +47,29 @@ def test_frames():
|
||||
basic_frame_check(frame)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_connection():
|
||||
devices = test_utils.TwoDevices()
|
||||
await devices.setup_connection()
|
||||
|
||||
accept_future: asyncio.Future[DLC] = asyncio.get_running_loop().create_future()
|
||||
channel = Server(devices[0]).listen(acceptor=accept_future.set_result)
|
||||
|
||||
multiplexer = await Client(devices.connections[1]).start()
|
||||
dlcs = await asyncio.gather(accept_future, multiplexer.open_dlc(channel))
|
||||
|
||||
queues = [asyncio.Queue(), asyncio.Queue()]
|
||||
for dlc, queue in zip(dlcs, queues):
|
||||
dlc.sink = queue.put_nowait
|
||||
|
||||
dlcs[0].write(b'The quick brown fox jumps over the lazy dog')
|
||||
assert await queues[1].get() == b'The quick brown fox jumps over the lazy dog'
|
||||
|
||||
dlcs[1].write(b'Lorem ipsum dolor sit amet')
|
||||
assert await queues[0].get() == b'Lorem ipsum dolor sit amet'
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
test_frames()
|
||||
|
||||
Reference in New Issue
Block a user