Skip to content

Commit

Permalink
Add test for covering DatabaseIsCorrupted handling in unhandled_error…
Browse files Browse the repository at this point in the history
…_observer
  • Loading branch information
kozlovsky committed Nov 23, 2023
1 parent 2a9fa6a commit 87cdda9
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tribler.core.components.reporter.exception_handler import CoreExceptionHandler
from tribler.core.sentry_reporter import sentry_reporter
from tribler.core.sentry_reporter.sentry_reporter import SentryReporter
from tribler.core.utilities.db_corruption_handling.base import DatabaseIsCorrupted


# pylint: disable=protected-access, redefined-outer-name
Expand Down Expand Up @@ -85,6 +86,17 @@ def test_unhandled_error_observer_exception(exception_handler):
assert reported_error.should_stop


@patch('tribler.core.components.reporter.exception_handler.get_global_process_manager')
def test_unhandled_error_observer_database_corrupted(get_global_process_manager, exception_handler):
# test that database corruption exception reported to the GUI
exception = DatabaseIsCorrupted('db_path_string')
exception_handler.report_callback = MagicMock()
exception_handler.unhandled_error_observer(None, {'exception': exception})

get_global_process_manager().sys_exit.assert_called_once_with(99, exception)
exception_handler.report_callback.assert_not_called()


def test_unhandled_error_observer_only_message(exception_handler):
# test that unhandled exception, represented by message, reported to the GUI
context = {'message': 'Any'}
Expand Down

0 comments on commit 87cdda9

Please sign in to comment.