-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Extract get_kind_from_index function and test it
Pull get_kind_from_index from class to module level and add tests. Related #1097
- Loading branch information
Showing
2 changed files
with
47 additions
and
17 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,26 @@ | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from logitech_receiver import exceptions, receiver | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"index, expected_kind", | ||
[ | ||
(0, None), | ||
(1, 2), # mouse | ||
(2, 2), # mouse | ||
(3, 1), # keyboard | ||
(4, 3), # numpad | ||
(5, None), | ||
], | ||
) | ||
def test_get_kind_from_index(index, expected_kind): | ||
mock_receiver = mock.Mock() | ||
|
||
if expected_kind: | ||
assert receiver.get_kind_from_index(index, mock_receiver) == expected_kind | ||
else: | ||
with pytest.raises(exceptions.NoSuchDevice): | ||
receiver.get_kind_from_index(index, mock_receiver) |