76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
import pytest
|
|
|
|
from logitech_receiver import base
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"usb_id, expected_name, expected_receiver_kind",
|
|
[
|
|
(0xC548, "Bolt Receiver", "bolt"),
|
|
(0xC52B, "Unifying Receiver", "unifying"),
|
|
(0xC531, "Nano Receiver", "nano"),
|
|
(0xC53F, "Lightspeed Receiver", None),
|
|
(0xC517, "EX100 Receiver 27 Mhz", "27Mhz"),
|
|
],
|
|
)
|
|
def test_product_information(usb_id, expected_name, expected_receiver_kind):
|
|
res = base.product_information(usb_id)
|
|
|
|
assert res["name"] == expected_name
|
|
assert isinstance(res["vendor_id"], int)
|
|
assert isinstance(res["product_id"], int)
|
|
|
|
if expected_receiver_kind:
|
|
assert res["receiver_kind"] == expected_receiver_kind
|
|
|
|
|
|
def test_filter_receivers_known():
|
|
bus_id = 2
|
|
vendor_id = 0x046D
|
|
product_id = 0xC548
|
|
|
|
receiver_info = base.filter_receivers(bus_id, vendor_id, product_id)
|
|
|
|
assert receiver_info["name"] == "Bolt Receiver"
|
|
assert receiver_info["receiver_kind"] == "bolt"
|
|
|
|
|
|
def test_filter_receivers_unknown():
|
|
bus_id = 1
|
|
vendor_id = 0x046D
|
|
product_id = 0xC500
|
|
|
|
receiver_info = base.filter_receivers(bus_id, vendor_id, product_id)
|
|
|
|
assert receiver_info["bus_id"] == bus_id
|
|
assert receiver_info["product_id"] == product_id
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"hidpp_short, hidpp_long",
|
|
[(True, False), (False, True), (False, False)],
|
|
)
|
|
def test_filter_products_of_interest(hidpp_short, hidpp_long):
|
|
bus_id = 3
|
|
vendor_id = 0x046D
|
|
product_id = 0xC07E
|
|
|
|
receiver_info = base.filter_products_of_interest(
|
|
bus_id,
|
|
vendor_id,
|
|
product_id,
|
|
hidpp_short=hidpp_short,
|
|
hidpp_long=hidpp_long,
|
|
)
|
|
|
|
assert receiver_info["bus_id"] == bus_id
|
|
assert receiver_info["product_id"] == product_id
|
|
|
|
|
|
def test_get_next_sw_id():
|
|
res1 = base._get_next_sw_id()
|
|
res2 = base._get_next_sw_id()
|
|
|
|
assert res1 == 2
|
|
assert res2 == 3
|