mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-30 21:39:56 +00:00
replace several store_true keys to booleanoptionalaction alternative (#74)
This commit is contained in:
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.database.data import migrate_package_statuses
|
||||
from ahriman.models.package import Package
|
||||
@ -22,11 +22,11 @@ def test_migrate_package_statuses(connection: Connection, package_ahriman: Packa
|
||||
|
||||
migrate_package_statuses(connection, repository_paths)
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
connection.executemany.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.data import migrate_users_data
|
||||
@ -16,6 +16,6 @@ def test_migrate_users_data(connection: Connection, configuration: Configuration
|
||||
|
||||
migrate_users_data(connection, configuration)
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
|
@ -2,8 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.migrations import Migrations
|
||||
@ -52,10 +51,10 @@ def test_run(migrations: Migrations, mocker: MockerFixture) -> None:
|
||||
migrations.run()
|
||||
validate_mock.assert_called_once_with()
|
||||
cursor.execute.assert_has_calls([
|
||||
mock.call("begin exclusive"),
|
||||
mock.call("select 1"),
|
||||
mock.call("pragma user_version = 1"),
|
||||
mock.call("commit"),
|
||||
MockCall("begin exclusive"),
|
||||
MockCall("select 1"),
|
||||
MockCall("pragma user_version = 1"),
|
||||
MockCall("commit"),
|
||||
])
|
||||
cursor.close.assert_called_once_with()
|
||||
migrate_data_mock.assert_called_once_with(
|
||||
@ -77,8 +76,8 @@ def test_run_migration_exception(migrations: Migrations, mocker: MockerFixture)
|
||||
with pytest.raises(Exception):
|
||||
migrations.run()
|
||||
cursor.execute.assert_has_calls([
|
||||
mock.call("begin exclusive"),
|
||||
mock.call("rollback"),
|
||||
MockCall("begin exclusive"),
|
||||
MockCall("rollback"),
|
||||
])
|
||||
cursor.close.assert_called_once_with()
|
||||
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
@ -17,8 +17,8 @@ def test_package_remove_package_base(database: SQLite, connection: Connection) -
|
||||
"""
|
||||
database._package_remove_package_base(connection, "package")
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
])
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user