def test__hid_write_with_fixed_packet_length(self, mouse): mouse._hid_write(packet_length=4) mouse._hid_device.bytes.seek(0) data = mouse._hid_device.bytes.read() assert len(data) == 6 assert data == b"\x02\x00\x00\x00\x00\x00"
def test__hid_write_with_a_wrong_report_type(self, mouse): with pytest.raises(ValueError): mouse._hid_write(report_type=0x42)
def test__hid_write_with_data(self, mouse): mouse._hid_write(report_type=usbhid.HID_REPORT_TYPE_OUTPUT, report_id=0x42, data=[0xDA, 0x7A]) mouse._hid_device.bytes.seek(0) assert mouse._hid_device.bytes.read() == b"\x02\x42\xDA\x7A"
def test__hid_write_with_a_valid_report_type(self, mouse, report_type, expected_hid_report): mouse._hid_write(report_type=report_type) mouse._hid_device.bytes.seek(0) assert mouse._hid_device.bytes.read() == expected_hid_report