forked from tahnok/colmi_r02_client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: starting testing client._handle_tx
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from unittest.mock import Mock | ||
import pytest | ||
|
||
from bleak.backends.characteristic import BleakGATTCharacteristic | ||
|
||
from colmi_r02_client.client import Client | ||
|
||
MOCK_CHAR = Mock(spec=BleakGATTCharacteristic) | ||
|
||
|
||
def test_handle_tx_short_packet(): | ||
client = Client("unused") | ||
|
||
with pytest.raises(AssertionError, match="Packet is the wrong length"): | ||
client._handle_tx(MOCK_CHAR, bytearray()) | ||
|
||
|
||
def test_handle_tx_error_bit(): | ||
client = Client("unused") | ||
|
||
with pytest.raises(AssertionError, match="Packet has error bit"): | ||
client._handle_tx(MOCK_CHAR, bytearray(b"\xf1" * 16)) |