mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-23 18:59:56 +00:00
remove unsafe flag from handlers
This flag became reduntant there and tree creation has been moved to lock
This commit is contained in:
@ -7,23 +7,23 @@ from ahriman.core.database import SQLite
|
||||
from ahriman.core.repository.cleaner import Cleaner
|
||||
from ahriman.core.repository.executor import Executor
|
||||
from ahriman.core.repository.update_handler import UpdateHandler
|
||||
from ahriman.models.pacman_synchronization import PacmanSynchronization
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cleaner(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> Cleaner:
|
||||
def cleaner(configuration: Configuration, database: SQLite) -> Cleaner:
|
||||
"""
|
||||
fixture for cleaner
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration fixture
|
||||
database(SQLite): database fixture
|
||||
mocker(MockerFixture): mocker object
|
||||
|
||||
Returns:
|
||||
Cleaner: cleaner test instance
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return Cleaner("x86_64", configuration, database, report=False, unsafe=False, refresh_pacman_database=0)
|
||||
return Cleaner("x86_64", configuration, database, report=False,
|
||||
refresh_pacman_database=PacmanSynchronization.Disabled)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -43,8 +43,8 @@ def executor(configuration: Configuration, database: SQLite, mocker: MockerFixtu
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_queue")
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return Executor("x86_64", configuration, database, report=False, unsafe=False, refresh_pacman_database=0)
|
||||
return Executor("x86_64", configuration, database, report=False,
|
||||
refresh_pacman_database=PacmanSynchronization.Disabled)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -64,5 +64,5 @@ def update_handler(configuration: Configuration, database: SQLite, mocker: Mocke
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_queue")
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return UpdateHandler("x86_64", configuration, database, report=False, unsafe=False, refresh_pacman_database=0)
|
||||
return UpdateHandler("x86_64", configuration, database, report=False,
|
||||
refresh_pacman_database=PacmanSynchronization.Disabled)
|
||||
|
@ -17,9 +17,8 @@ def test_load(configuration: Configuration, database: SQLite, mocker: MockerFixt
|
||||
"""
|
||||
must correctly load instance
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
context_mock = mocker.patch("ahriman.core.repository.Repository._set_context")
|
||||
Repository.load("x86_64", configuration, database, report=False, unsafe=False)
|
||||
Repository.load("x86_64", configuration, database, report=False)
|
||||
context_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -27,10 +26,9 @@ def test_set_context(configuration: Configuration, database: SQLite, mocker: Moc
|
||||
"""
|
||||
must set context variables
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
set_mock = mocker.patch("ahriman.core._Context.set")
|
||||
|
||||
instance = Repository.load("x86_64", configuration, database, report=False, unsafe=False)
|
||||
instance = Repository.load("x86_64", configuration, database, report=False)
|
||||
set_mock.assert_has_calls([
|
||||
MockCall(ContextKey("database", SQLite), instance.database),
|
||||
MockCall(ContextKey("configuration", Configuration), instance.configuration),
|
||||
|
@ -1,39 +1,11 @@
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import UnsafeRunError
|
||||
from ahriman.core.repository.repository_properties import RepositoryProperties
|
||||
from ahriman.models.packagers import Packagers
|
||||
from ahriman.models.pacman_synchronization import PacmanSynchronization
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
|
||||
|
||||
def test_create_tree_on_load(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create tree on load
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository_properties.check_user")
|
||||
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False,
|
||||
refresh_pacman_database=PacmanSynchronization.Disabled)
|
||||
|
||||
tree_create_mock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_create_tree_on_load_unsafe(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must not create tree on load in case if user differs from the root owner
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository_properties.check_user", side_effect=UnsafeRunError(0, 1))
|
||||
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False,
|
||||
refresh_pacman_database=PacmanSynchronization.Disabled)
|
||||
|
||||
tree_create_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_packager(repository: RepositoryProperties, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must extract packager
|
||||
|
@ -19,7 +19,7 @@ def test_force_no_report(configuration: Configuration, database: SQLite, mocker:
|
||||
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
|
||||
|
||||
Watcher("x86_64", configuration, database)
|
||||
load_mock.assert_called_once_with("x86_64", configuration, database, report=False, unsafe=False)
|
||||
load_mock.assert_called_once_with("x86_64", configuration, database, report=False)
|
||||
|
||||
|
||||
def test_get(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
|
Reference in New Issue
Block a user