Skip to content

Commit

Permalink
Do not call on_success if response contains no data
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Mar 24, 2023
1 parent 654f139 commit a9cb07c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/tribler/gui/network/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def on_finished(self):
return

if not data:
self.on_finished_signal.emit({})
self.logger.error(f'No data received in the reply for {self}')
return

self.logger.debug('Create a json response')
Expand Down
4 changes: 2 additions & 2 deletions src/tribler/gui/network/tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def test_str_data_constructor():

def test_on_finished():
# Test that if 'request.reply' is empty, the `on_finish` method is called with an empty dict.
# see: https://github.com/Tribler/tribler/issues/7297
# see: https://github.com/Tribler/tribler/issues/7333
on_success = MagicMock()
request = Request(endpoint='endpoint', on_success=on_success)
request.manager = MagicMock()
request.reply = MagicMock(readAll=MagicMock(return_value=b''))

request.on_finished()

on_success.assert_called_once_with({})
on_success.assert_not_called()

0 comments on commit a9cb07c

Please sign in to comment.