forked from pwr-Solaar/Solaar
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Feature NamedInts to SupportedFeature integer enum. Related pwr-Solaar#2273
- Loading branch information
Showing
2 changed files
with
88 additions
and
27 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,39 @@ | ||
import pytest | ||
|
||
from logitech_receiver import hidpp10_constants | ||
from logitech_receiver import notifications | ||
from logitech_receiver.base import HIDPPNotification | ||
from logitech_receiver.hidpp10_constants import Registers | ||
from logitech_receiver.receiver import Receiver | ||
|
||
|
||
class MockLowLevelInterface: | ||
def open_path(self, path): | ||
pass | ||
|
||
def find_paired_node_wpid(self, receiver_path: str, index: int): | ||
pass | ||
|
||
def ping(self, handle, number, long_message=False): | ||
pass | ||
|
||
def request(self, handle, devnumber, request_id, *params, **kwargs): | ||
pass | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"sub_id, notification_data, expected_error, expected_new_device", | ||
[ | ||
(Registers.DISCOVERY_STATUS_NOTIFICATION, b"\x01", "device_timeout", None), | ||
(Registers.PAIRING_STATUS_NOTIFICATION, b"\x02", "failed", None), | ||
], | ||
) | ||
def test_process_receiver_notification(sub_id, notification_data, expected_error, expected_new_device): | ||
receiver: Receiver = Receiver(MockLowLevelInterface(), None, {}, True, None, None) | ||
notification = HIDPPNotification(0, 0, sub_id, 0, notification_data) | ||
|
||
result = notifications._process_receiver_notification(receiver, notification) | ||
|
||
assert result | ||
assert receiver.pairing.error == hidpp10_constants.BOLT_PAIRING_ERRORS[expected_error] | ||
assert receiver.pairing.new_device is expected_new_device |