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.
Introduce integrationtests for listeners
- Loading branch information
Showing
5 changed files
with
67 additions
and
4 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,17 @@ | ||
import platform | ||
|
||
import pytest | ||
|
||
from hidapi.hidapi_impl import DeviceMonitor | ||
|
||
|
||
@pytest.mark.skipif(platform.system() == "Linux", reason="Test for non Linux platforms") | ||
def test_device_monitor(mocker): | ||
mock_callback = mocker.Mock() | ||
|
||
monitor = DeviceMonitor(device_callback=mock_callback, polling_delay=0.1) | ||
monitor.start() | ||
|
||
monitor.join(5) | ||
|
||
mock_callback.assert_not_called() |
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,16 @@ | ||
from logitech_receiver.listener import EventsListener | ||
|
||
|
||
def test_events_listener(mocker): | ||
receiver = mocker.MagicMock() | ||
status_callback = mocker.MagicMock() | ||
|
||
e = EventsListener(receiver, status_callback) | ||
e.start() | ||
|
||
assert bool(e) | ||
|
||
e.stop() | ||
|
||
assert not bool(e) | ||
assert status_callback.call_count == 0 |
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,15 @@ | ||
from solaar.listener import SolaarListener | ||
|
||
|
||
def test_solaar_listener(mocker): | ||
receiver = mocker.MagicMock() | ||
receiver.handle = 1 | ||
receiver.path = "dsda" | ||
status_callback = mocker.MagicMock() | ||
|
||
rl = SolaarListener(receiver, status_callback) | ||
# rl.run() | ||
# rl.stop() | ||
|
||
assert not rl.is_alive() | ||
assert status_callback.call_count == 0 |
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,15 @@ | ||
from solaar import tasks | ||
|
||
|
||
def run_task(): | ||
print("Hi!") | ||
|
||
|
||
def test_task_runner(mocker): | ||
tr = tasks.TaskRunner(name="Testrunner") | ||
tr.queue.put((run_task, {}, {})) | ||
# tr.run() | ||
# tr.stop() | ||
# assert tr.alive | ||
# tr.stop() | ||
# assert not tr.alive |