Skip to content

Commit

Permalink
Introduce integrationtests for listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHag committed Nov 6, 2024
1 parent b34729b commit e4ae732
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/integrationtests/test_device_monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from hidapi import hidapi_impl


def test_device_monitor(mocker):
mock_callback = mocker.Mock()

monitor = hidapi_impl._DeviceMonitor(device_callback=mock_callback)
monitor.start()

mock_callback.assert_not_called()
16 changes: 16 additions & 0 deletions tests/integrationtests/test_events_listener.py
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
15 changes: 15 additions & 0 deletions tests/integrationtests/test_solaar_listener.py
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
15 changes: 15 additions & 0 deletions tests/integrationtests/test_task_runner.py
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

0 comments on commit e4ae732

Please sign in to comment.