Skip to content

Commit

Permalink
More tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Oct 2, 2023
1 parent 02ee0b5 commit 919c1a6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/tribler/core/components/libtorrent/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,34 @@ def test_tracker_error_alert_unicode_decode_error(test_download: Download, caplo
"(exception in .url)")


def test_tracker_error_alert_has_msg(test_download: Download):
alert = MagicMock(__repr__=Mock(return_value='<ALERT_REPR>'), url='<ALERT_URL>', msg='<ALERT_MSG>')
assert alert.url not in test_download.tracker_status
test_download.on_tracker_error_alert(alert)
assert test_download.tracker_status[alert.url] == [0, 'Error: <ALERT_MSG>']


def test_tracker_error_alert_has_positive_status_code(test_download: Download):
alert = MagicMock(__repr__=Mock(return_value='<ALERT_REPR>'), url='<ALERT_URL>', msg=None, status_code=123)
assert alert.url not in test_download.tracker_status
test_download.on_tracker_error_alert(alert)
assert test_download.tracker_status[alert.url] == [0, 'HTTP status code 123']


def test_tracker_error_alert_has_status_code_zero(test_download: Download):
alert = MagicMock(__repr__=Mock(return_value='<ALERT_REPR>'), url='<ALERT_URL>', msg=None, status_code=0)
assert alert.url not in test_download.tracker_status
test_download.on_tracker_error_alert(alert)
assert test_download.tracker_status[alert.url] == [0, 'Timeout']


def test_tracker_error_alert_has_negative_status_code(test_download: Download):
alert = MagicMock(__repr__=Mock(return_value='<ALERT_REPR>'), url='<ALERT_URL>', msg=None, status_code=-1)
assert alert.url not in test_download.tracker_status
test_download.on_tracker_error_alert(alert)
assert test_download.tracker_status[alert.url] == [0, 'Not working']


def test_tracker_warning_alert(test_download):
"""
Test whether a tracking warning alert is processed correctly
Expand Down

0 comments on commit 919c1a6

Please sign in to comment.