From a1414c2b5bc7816d46418b2ef2b59117db8cc77d Mon Sep 17 00:00:00 2001 From: Gilles Boccon-Gibod Date: Sun, 3 Nov 2024 19:08:27 -0800 Subject: [PATCH] add unsubscribe test --- tests/gatt_test.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/gatt_test.py b/tests/gatt_test.py index f783cae9..8d73eb3f 100644 --- a/tests/gatt_test.py +++ b/tests/gatt_test.py @@ -851,7 +851,12 @@ async def test_unsubscribe(): await async_barrier() mock1.assert_called_once_with(ANY, True, False) - await c2.subscribe() + assert len(server.gatt_server.subscribers) == 1 + + def callback(_): + pass + + await c2.subscribe(callback) await async_barrier() mock2.assert_called_once_with(ANY, True, False) @@ -861,10 +866,16 @@ async def test_unsubscribe(): mock1.assert_called_once_with(ANY, False, False) mock2.reset_mock() - await c2.unsubscribe() + await c2.unsubscribe(callback) await async_barrier() mock2.assert_called_once_with(ANY, False, False) + # All CCCDs should be zeros now + assert list(server.gatt_server.subscribers.values())[0] == { + c1.handle: bytes([0, 0]), + c2.handle: bytes([0, 0]), + } + mock1.reset_mock() await c1.unsubscribe() await async_barrier()