Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test diversion rules #2620

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9e6bd8b
hidapi: Completely remove dependency on gi
MattHag Sep 20, 2024
f3ce935
Clarify that fake hidpp is used
MattHag Sep 15, 2024
e638250
Simplify setup with pathlib
MattHag Sep 15, 2024
7b4d93a
Fix test coverage reporting
MattHag Sep 18, 2024
37f4be1
Introduce test coverage threshold
MattHag Sep 18, 2024
ef54d28
Setup reports and upload codecov
MattHag Sep 19, 2024
9e946a0
Add code coverage badge
MattHag Sep 19, 2024
f6ac185
Rename lr/notify module to desktop_notifications
MattHag Sep 18, 2024
be81eea
Make lr/desktop_notifications testable
MattHag Sep 18, 2024
8db32bd
Rename ui/notify module to desktop notifications
MattHag Sep 18, 2024
bc82f79
Make ui/desktop_notifications testable
MattHag Sep 18, 2024
ef65d79
settings_template: Prepare removal of desktop_notifications dependency
MattHag Sep 18, 2024
823bf29
base: Simplify receiver info retrieval
MattHag Sep 15, 2024
0212338
Replace global sw_id with function call
MattHag Sep 15, 2024
61a27d5
base: Add type hints
MattHag Sep 15, 2024
f4866f7
solaar: Add type hints
MattHag Sep 15, 2024
563d56a
Upload test coverage reports solely after merging (#7)
MattHag Sep 25, 2024
337eb4a
keysymdef: Rename key symbols
MattHag Sep 25, 2024
c58075b
keysyms: Introduce tests for this package
MattHag Sep 25, 2024
b127e6e
Test coverage: Fix keysyms to be visible (#9)
MattHag Sep 25, 2024
b9eed6c
device: Remove hard dependency on hidapi
MattHag Sep 25, 2024
2182d90
receiver: Remove hard dependency on hidapi
MattHag Sep 25, 2024
2705f57
hidapi: Explicitly load hidapi/udev implementation
MattHag Sep 26, 2024
65d738f
ui/about: Use Model-View-Presenter pattern for testability
MattHag Sep 26, 2024
be196b5
base_usb: Add external interface
MattHag Sep 27, 2024
755d2f0
Fix about dialog
MattHag Sep 27, 2024
96a801c
base: Add find_paired_node functions
MattHag Sep 28, 2024
a6ec5bf
base: Add find_paired_node functions
MattHag Sep 28, 2024
c04392b
Add type hints and clean up
MattHag Sep 28, 2024
2ca2246
base: Add test for filter_products_of_interest
MattHag Sep 28, 2024
8f82de6
device: Remove hard dependency on base
MattHag Sep 28, 2024
42b7a48
receiver: Remove hard dependency on base
MattHag Sep 28, 2024
36b7f63
Remove factory wrapper classes
MattHag Sep 28, 2024
dec3f88
Replace action strings with constants
MattHag Sep 28, 2024
4cb7743
settings_template: Introduce State enum
MattHag Sep 28, 2024
aaa324d
settings: Add tests
MattHag Sep 28, 2024
353abb0
ui/common: Introduce tests
MattHag Sep 28, 2024
c8f0699
Fix warnings from automatic code inspections
MattHag Sep 30, 2024
1484717
Introduce HIDAPI protocol
MattHag Oct 1, 2024
9e10039
base: Add more unit tests
MattHag Oct 2, 2024
d22b3f9
base: Remove hard dependency on gi
MattHag Oct 2, 2024
ded78ea
Remove obsolete pytest fixture
MattHag Oct 2, 2024
7534800
diversion: Add type hints
MattHag Oct 2, 2024
73fdf32
Fix rule saving command
MattHag Oct 6, 2024
9da3a0e
Action menu: Move context menu into own class
MattHag Oct 6, 2024
92c981b
Fix signature of show
MattHag Oct 6, 2024
ae09bec
diversion_rules: Add type hints
MattHag Oct 6, 2024
9314f22
rule_conditions: Introduce tests
MattHag Oct 6, 2024
bb23443
RuleComponentUI: Type hints methods
MattHag Oct 6, 2024
ef1f58b
diversion_rules: Introduce tests
MattHag Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[run]
branch = True

source =
hid_parser
hidapi
keysyms
logitech_receiver
solaar

omit =
*/tests/*
*/setup.py
*/__main__.py

[report]
exclude_lines =
pragma: no cover
if __name__ == '__main__':
if typing.TYPE_CHECKING

fail_under = 40
23 changes: 22 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ jobs:
run: |
make test

- name: Upload coverage to Codecov
if: github.ref == 'refs/heads/master'
uses: codecov/codecov-action@v4.5.0
with:
directory: ./coverage/reports/
env_vars: OS, PYTHON
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}

macos-tests:
runs-on: macos-latest

Expand All @@ -55,4 +66,14 @@ jobs:
make install_pip PIP_ARGS='.["test"]'
- name: Run tests on macOS
run: |
export DYLD_LIBRARY_PATH=$(brew --prefix hidapi)/lib:$DYLD_LIBRARY_PATH && pytest --cov=lib/ tests/
export DYLD_LIBRARY_PATH=$(brew --prefix hidapi)/lib:$DYLD_LIBRARY_PATH && pytest --cov --cov-report=xml
- name: Upload coverage to Codecov
if: github.ref == 'refs/heads/master'
uses: codecov/codecov-action@v4.5.0
with:
directory: ./coverage/reports/
env_vars: OS, PYTHON
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ lint:

test:
@echo "Running Solaar tests"
pytest --cov=lib/ tests/
pytest --cov --cov-report=xml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ that are otherwise ignored by the Linux input system.
<a href="https://pwr-solaar.github.io/Solaar/installation">Manual Installation</a>


[![codecov](https://codecov.io/gh/pwr-Solaar/Solaar/graph/badge.svg?token=D7YWFEWID6)](https://codecov.io/gh/pwr-Solaar/Solaar)
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](../LICENSE.txt)

<p align="center">
Expand Down
1 change: 1 addition & 0 deletions bin/solaar
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def init_paths():
import sys

# Python 3 might have problems converting back to UTF-8 in case of Unicode surrogates
decoded_path = None
try:
decoded_path = sys.path[0]
sys.path[0].encode(sys.getfilesystemencoding())
Expand Down
21 changes: 18 additions & 3 deletions lib/hid_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ def parse(self, data: Sequence[int]) -> Dict[Usage, UsageValue]:
)
continue

if usage in self._usages and all(usage_type not in self._INCOMPATIBLE_TYPES for usage_type in usage.usage_types):
not_incompatible_type = all(usage_type not in self._INCOMPATIBLE_TYPES for usage_type in usage.usage_types)
if usage in self._usages and not_incompatible_type:
usage_values[usage] = UsageValue(self, True)

return usage_values
Expand Down Expand Up @@ -820,14 +821,28 @@ def _parse(self, level: int = 0, file: TextIO = sys.stdout) -> None: # noqa: C9
if data is None:
raise InvalidReportDescriptor("Invalid output item")
self._append_items(
offset_output, self._output, report_id, report_count, report_size, usages, data, {**glob, **local}
offset_output,
self._output,
report_id,
report_count,
report_size,
usages,
data,
{**glob, **local},
)

elif tag == TagMain.FEATURE:
if data is None:
raise InvalidReportDescriptor("Invalid feature item")
self._append_items(
offset_feature, self._feature, report_id, report_count, report_size, usages, data, {**glob, **local}
offset_feature,
self._feature,
report_id,
report_count,
report_size,
usages,
data,
{**glob, **local},
)

# clear local
Expand Down
47 changes: 0 additions & 47 deletions lib/hidapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,47 +0,0 @@
## Copyright (C) 2012-2013 Daniel Pavel
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""Generic Human Interface Device API."""

import platform

if platform.system() in ("Darwin", "Windows"):
from hidapi.hidapi_impl import close # noqa: F401
from hidapi.hidapi_impl import enumerate # noqa: F401
from hidapi.hidapi_impl import find_paired_node # noqa: F401
from hidapi.hidapi_impl import find_paired_node_wpid # noqa: F401
from hidapi.hidapi_impl import get_manufacturer # noqa: F401
from hidapi.hidapi_impl import get_product # noqa: F401
from hidapi.hidapi_impl import get_serial # noqa: F401
from hidapi.hidapi_impl import monitor_glib # noqa: F401
from hidapi.hidapi_impl import open # noqa: F401
from hidapi.hidapi_impl import open_path # noqa: F401
from hidapi.hidapi_impl import read # noqa: F401
from hidapi.hidapi_impl import write # noqa: F401
else:
from hidapi.udev_impl import close # noqa: F401
from hidapi.udev_impl import enumerate # noqa: F401
from hidapi.udev_impl import find_paired_node # noqa: F401
from hidapi.udev_impl import find_paired_node_wpid # noqa: F401
from hidapi.udev_impl import get_manufacturer # noqa: F401
from hidapi.udev_impl import get_product # noqa: F401
from hidapi.udev_impl import get_serial # noqa: F401
from hidapi.udev_impl import monitor_glib # noqa: F401
from hidapi.udev_impl import open # noqa: F401
from hidapi.udev_impl import open_path # noqa: F401
from hidapi.udev_impl import read # noqa: F401
from hidapi.udev_impl import write # noqa: F401

__version__ = "0.9"
20 changes: 11 additions & 9 deletions lib/hidapi/common.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from __future__ import annotations

import dataclasses


@dataclasses.dataclass
class DeviceInfo:
path: str
bus_id: str
bus_id: str | None
vendor_id: str
product_id: str
interface: str
driver: str
manufacturer: str
product: str
serial: str
release: str
interface: str | None
driver: str | None
manufacturer: str | None
product: str | None
serial: str | None
release: str | None
isDevice: bool
hidpp_short: str
hidpp_long: str
hidpp_short: str | None
hidpp_long: str | None
Loading
Loading