Skip to content

Commit

Permalink
Merge pull request #583 from google/gbg/more-gatt-tests
Browse files Browse the repository at this point in the history
regression test for GATT unsubscription
  • Loading branch information
barbibulle authored Nov 4, 2024
2 parents a06394a + a1414c2 commit a060a70
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/gatt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand Down

0 comments on commit a060a70

Please sign in to comment.