-
Notifications
You must be signed in to change notification settings - Fork 445
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 #7685 from drew2a/fix/7601
Handle an absent `db_version` for Upgrader.
- Loading branch information
Showing
2 changed files
with
15 additions
and
1 deletion.
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,11 @@ | ||
from unittest.mock import MagicMock, Mock, patch | ||
|
||
from tribler.core.upgrade.db8_to_db10 import get_db_version | ||
from tribler.core.utilities.path_util import Path | ||
|
||
|
||
def test_get_db_version_no_db_version(): | ||
""" Test that get_db_version returns 0 if the database version is not found.""" | ||
cursor = Mock(return_value=Mock(fetchone=Mock(return_value=None))) | ||
with patch('tribler.core.upgrade.db8_to_db10.sqlite3.connect', return_value=MagicMock(cursor=cursor)): | ||
assert get_db_version(Path()) == 0 |