-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7593 from drew2a/feature/7424
Refactor the FeedbackDialog
- Loading branch information
Showing
6 changed files
with
162 additions
and
142 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
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
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,53 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
from tribler.gui.dialogs.feedbackdialog import dump, dump_with_name | ||
|
||
|
||
def test_dump_with_name_start(): | ||
""" Test dump_with_name with a start value""" | ||
actual = dump_with_name('name', 'value', 'start') | ||
expected = ('start========================================\n' | ||
'name:\n' | ||
'========================================\n' | ||
"'value'") | ||
|
||
assert actual == expected | ||
|
||
|
||
@patch('tribler.gui.dialogs.feedbackdialog.dump') | ||
def test_dump_with_name_str(mock_dump: Mock): | ||
""" Test that dump_with_name calls the `dump` function""" | ||
dump_with_name('name', 'value') | ||
assert mock_dump.called | ||
|
||
|
||
def test_dump_none(): | ||
""" Test dump with a None value""" | ||
assert dump(None) == 'None' | ||
|
||
|
||
def test_dump_dict(): | ||
""" Test dump with a complex dict value""" | ||
actual = dump( | ||
{ | ||
|
||
'key': { | ||
'key1': 'value1' | ||
}, | ||
'key2': 'value2', | ||
'key3': ['value3', 'value4'] | ||
} | ||
) | ||
|
||
expected = ('{\n' | ||
" 'key': {\n" | ||
" 'key1': 'value1'\n" | ||
' },\n' | ||
" 'key2': 'value2',\n" | ||
" 'key3': [\n" | ||
" 'value3',\n" | ||
" 'value4'\n" | ||
' ]\n' | ||
'}') | ||
|
||
assert actual == expected |
Oops, something went wrong.