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.
- Loading branch information
Showing
2 changed files
with
42 additions
and
11 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,28 @@ | ||
from unittest import mock | ||
from unittest.mock import PropertyMock | ||
|
||
import pytest | ||
|
||
from solaar.ui import common | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"reason, expected_in_title, expected_in_text", | ||
[ | ||
( | ||
"permissions", | ||
"Permissions error", | ||
"not have permission to open", | ||
), | ||
("nodevice", "connect to device error", "error connecting"), | ||
("unpair", "Unpairing failed", "receiver returned an error"), | ||
], | ||
) | ||
def test_create_error_text(reason, expected_in_title, expected_in_text): | ||
obj = mock.Mock() | ||
obj.name = PropertyMock(return_value="test") | ||
|
||
title, text = common._create_error_text(reason, obj) | ||
|
||
assert expected_in_title in title | ||
assert expected_in_text in text |