shorten public imports

This commit is contained in:
2022-05-06 04:08:05 +03:00
parent 2dac5a2520
commit 7f87863734
139 changed files with 374 additions and 373 deletions

View File

@ -6,7 +6,7 @@ from ahriman.application.application.application_packages import ApplicationPack
from ahriman.application.application.application_properties import ApplicationProperties
from ahriman.application.application.application_repository import ApplicationRepository
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
@pytest.fixture
@ -23,7 +23,7 @@ def application_packages(configuration: Configuration, database: SQLite, mocker:
ApplicationPackages: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationPackages("x86_64", configuration, no_report=True, unsafe=False)
@ -42,7 +42,7 @@ def application_properties(configuration: Configuration, database: SQLite,
ApplicationProperties: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationProperties("x86_64", configuration, no_report=True, unsafe=False)
@ -61,5 +61,5 @@ def application_repository(configuration: Configuration, database: SQLite,
ApplicationRepository: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationRepository("x86_64", configuration, no_report=True, unsafe=False)

View File

@ -48,8 +48,8 @@ def test_add_aur(application_packages: ApplicationPackages, package_ahriman: Pac
load_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.load")
dependencies_mock = mocker.patch(
"ahriman.application.application.application_packages.ApplicationPackages._process_dependencies")
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
update_remote_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.remote_update")
build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert")
update_remote_mock = mocker.patch("ahriman.core.database.SQLite.remote_update")
application_packages._add_aur(package_ahriman.base, set(), False)
load_mock.assert_called_once_with(
@ -87,7 +87,7 @@ def test_add_local(application_packages: ApplicationPackages, package_ahriman: P
copytree_mock = mocker.patch("shutil.copytree")
dependencies_mock = mocker.patch(
"ahriman.application.application.application_packages.ApplicationPackages._process_dependencies")
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert")
application_packages._add_local(package_ahriman.base, set(), False)
copytree_mock.assert_called_once_with(
@ -120,8 +120,8 @@ def test_add_repository(application_packages: ApplicationPackages, package_ahrim
must add package from official repository
"""
mocker.patch("ahriman.models.package.Package.from_official", return_value=package_ahriman)
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_insert")
update_remote_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.remote_update")
build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_insert")
update_remote_mock = mocker.patch("ahriman.core.database.SQLite.remote_update")
application_packages._add_repository(package_ahriman.base)
build_queue_mock.assert_called_once_with(package_ahriman)

View File

@ -7,7 +7,7 @@ from ahriman.application.ahriman import _parser
from ahriman.application.application import Application
from ahriman.application.lock import Lock
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
@pytest.fixture
@ -24,7 +24,7 @@ def application(configuration: Configuration, database: SQLite, mocker: MockerFi
Application: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return Application("x86_64", configuration, no_report=True, unsafe=False)

View File

@ -52,7 +52,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
mocker.patch("ahriman.application.application.Application.add")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
Add.run(args, "x86_64", configuration, True, False)
@ -72,7 +72,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
mocker.patch("ahriman.application.application.Application.updates")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Add.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)

View File

@ -46,7 +46,7 @@ def test_get_paths(configuration: Configuration, mocker: MockerFixture) -> None:
mocker.patch.object(RepositoryPaths, "root_owner", (42, 42))
getpwuid_mock = mocker.patch("pwd.getpwuid", return_value=MagicMock())
# well database does not exist so we override it
database_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.database_path", return_value=configuration.path)
database_mock = mocker.patch("ahriman.core.database.SQLite.database_path", return_value=configuration.path)
paths = Backup.get_paths(configuration)
getpwuid_mock.assert_called_once_with(42)

View File

@ -11,7 +11,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump",
return_value=configuration.dump())

View File

@ -35,7 +35,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
args = _default_args(args)
args.action = Action.Update
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_create")
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), Path(args.package), args.track)
@ -48,7 +48,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, mocker
args = _default_args(args)
args.action = Action.List
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list")
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list")
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, False)
@ -61,7 +61,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
args = _default_args(args)
args.action = Action.Remove
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove")
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package)
@ -71,9 +71,9 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None
"""
must list available patches for the command
"""
get_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_list", return_value={"ahriman": "patch"})
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
get_mock = mocker.patch("ahriman.core.database.SQLite.patches_list", return_value={"ahriman": "patch"})
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Patch.patch_set_list(application, "ahriman", False)
get_mock.assert_called_once_with("ahriman")
@ -85,8 +85,8 @@ def test_patch_set_list_empty_exception(application: Application, mocker: Mocker
"""
must raise ExitCode exception on empty patch list
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.patches_list", return_value={})
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
mocker.patch("ahriman.core.database.SQLite.patches_list", return_value={})
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Patch.patch_set_list(application, "ahriman", True)
check_mock.assert_called_once_with(True, True)
@ -99,7 +99,7 @@ def test_patch_set_create(application: Application, package_ahriman: Package, mo
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create", return_value="patch")
create_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_insert")
create_mock = mocker.patch("ahriman.core.database.SQLite.patches_insert")
Patch.patch_set_create(application, Path("path"), ["*.patch"])
create_mock.assert_called_once_with(package_ahriman.base, "patch")
@ -109,6 +109,6 @@ def test_patch_set_remove(application: Application, package_ahriman: Package, mo
"""
must remove patch set for the package
"""
remove_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove")
remove_mock = mocker.patch("ahriman.core.database.SQLite.patches_remove")
Patch.patch_set_remove(application, package_ahriman.base)
remove_mock.assert_called_once_with(package_ahriman.base)

View File

@ -40,7 +40,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on",
return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Rebuild.run(args, "x86_64", configuration, True, False)
application_packages_mock.assert_called_once_with(None)
@ -73,7 +73,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration,
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Rebuild.run(args, "x86_64", configuration, True, False)
application_mock.assert_not_called()
@ -117,7 +117,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
args.dry_run = True
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Rebuild.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)
@ -133,7 +133,7 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman])
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Rebuild.run(args, "x86_64", configuration, True, False)
check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)])
@ -143,6 +143,6 @@ def test_extract_packages(application: Application, mocker: MockerFixture) -> No
"""
must extract packages from database
"""
packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get")
packages_mock = mocker.patch("ahriman.core.database.SQLite.packages_get")
Rebuild.extract_packages(application)
packages_mock.assert_called_once_with()

View File

@ -49,7 +49,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, pac
application_mock = mocker.patch("ahriman.application.application.Application.unknown",
return_value=[package_ahriman])
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
RemoveUnknown.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with()
@ -69,7 +69,7 @@ def test_run_dry_run_verbose(args: argparse.Namespace, configuration: Configurat
application_mock = mocker.patch("ahriman.application.application.Application.unknown",
return_value=[package_ahriman])
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
RemoveUnknown.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with()

View File

@ -35,11 +35,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, aur_package
"""
args = _default_args(args)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
aur_search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman])
official_search_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch",
aur_search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
official_search_mock = mocker.patch("ahriman.core.alpm.remote.Official.multisearch",
return_value=[aur_package_ahriman])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Search.run(args, "x86_64", configuration, True, False)
aur_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int))
@ -54,11 +54,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
"""
args = _default_args(args)
args.exit_code = True
mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[])
mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[])
mocker.patch("ahriman.core.formatters.printer.Printer.print")
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[])
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
mocker.patch("ahriman.core.formatters.Printer.print")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Search.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)
@ -70,10 +70,10 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, aur_pa
must run command with sorting
"""
args = _default_args(args)
mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman])
mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[])
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
Search.run(args, "x86_64", configuration, True, False)
sort_mock.assert_has_calls([
@ -89,10 +89,10 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, aur
"""
args = _default_args(args)
args.sort_by = "field"
mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman])
mocker.patch("ahriman.core.alpm.remote.official.Official.multisearch", return_value=[])
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
Search.run(args, "x86_64", configuration, True, False)
sort_mock.assert_has_calls([

View File

@ -39,11 +39,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
"""
args = _default_args(args)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_ahriman")
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_devtools")
makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_makepkg")
sudo_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_sudo")
executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.executable_create")
ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_ahriman")
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools")
makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_makepkg")
sudo_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo")
executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create")
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
paths = RepositoryPaths(configuration.getpath("repository", "root"), "x86_64")

View File

@ -38,8 +38,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr
packages_mock = mocker.patch("ahriman.core.status.client.Client.get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)),
(package_python_schedule, BuildStatus(BuildStatusEnum.Failed))])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Status.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with()
@ -57,7 +57,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.status.client.Client.get_self")
mocker.patch("ahriman.core.status.client.Client.get", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Status.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)
@ -73,7 +73,7 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, pac
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.status.client.Client.get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Status.run(args, "x86_64", configuration, True, False)
print_mock.assert_has_calls([mock.call(True) for _ in range(2)])
@ -105,7 +105,7 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, p
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)),
(package_python_schedule, BuildStatus(BuildStatusEnum.Failed))])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Status.run(args, "x86_64", configuration, True, False)
print_mock.assert_has_calls([mock.call(False) for _ in range(2)])

View File

@ -30,7 +30,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
args = _default_args(args)
commands_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.get_unsafe_commands",
return_value=["command"])
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
UnsafeCommands.run(args, "x86_64", configuration, True, False)
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
@ -56,7 +56,7 @@ def test_check_unsafe(mocker: MockerFixture) -> None:
"""
must check if command is unsafe
"""
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
UnsafeCommands.check_unsafe("repo-clean", ["repo-clean"], _parser())
check_mock.assert_called_once_with(True, True)
@ -65,7 +65,7 @@ def test_check_unsafe_safe(mocker: MockerFixture) -> None:
"""
must check if command is safe
"""
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
UnsafeCommands.check_unsafe("package-status", ["repo-clean"], _parser())
check_mock.assert_called_once_with(True, False)

View File

@ -41,7 +41,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
result.add_success(package_ahriman)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
Update.run(args, "x86_64", configuration, True, False)
@ -60,7 +60,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
args.dry_run = True
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Update.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)
@ -76,7 +76,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Update.run(args, "x86_64", configuration, True, False)
check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)])
@ -90,7 +90,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, moc
args.dry_run = True
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update")
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
updates_mock = mocker.patch("ahriman.application.application.Application.updates")
Update.run(args, "x86_64", configuration, True, False)

View File

@ -6,7 +6,7 @@ from pytest_mock import MockerFixture
from ahriman.application.handlers import Users
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.exceptions import InitializeException
from ahriman.models.action import Action
from ahriman.models.user import User
@ -39,13 +39,13 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S
"""
args = _default_args(args)
user = User(args.username, args.password, args.role)
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.Users.configuration_get")
create_configuration_mock = mocker.patch("ahriman.application.handlers.Users.configuration_create")
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
get_salt_mock = mocker.patch("ahriman.application.handlers.Users.get_salt", return_value="salt")
update_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_update")
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
Users.run(args, "x86_64", configuration, True, False)
get_auth_configuration_mock.assert_called_once_with(configuration.include)
@ -63,9 +63,9 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa
"""
args = _default_args(args)
args.action = Action.List
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
list_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_list", return_value=[user])
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user])
Users.run(args, "x86_64", configuration, True, False)
list_mock.assert_called_once_with("user", args.role)
@ -80,9 +80,9 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
args = _default_args(args)
args.action = Action.List
args.exit_code = True
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.sqlite.SQLite.user_list", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_if_empty")
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Users.run(args, "x86_64", configuration, True, False)
check_mock.assert_called_once_with(True, True)
@ -95,8 +95,8 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, data
"""
args = _default_args(args)
args.action = Action.Remove
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
remove_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.user_remove")
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
remove_mock = mocker.patch("ahriman.core.database.SQLite.user_remove")
Users.run(args, "x86_64", configuration, True, False)
remove_mock.assert_called_once_with(args.username)

View File

@ -7,9 +7,9 @@ from typing import Any, Dict, Type, TypeVar
from unittest.mock import MagicMock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.auth.auth import Auth
from ahriman.core.auth import Auth
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.spawn import Spawn
from ahriman.core.status.watcher import Watcher
from ahriman.models.aur_package import AURPackage

View File

@ -1,9 +1,6 @@
import pytest
from ahriman.core.alpm.remote.aur import AUR
from ahriman.core.alpm.remote.official import Official
from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb
from ahriman.core.alpm.remote.remote import Remote
from ahriman.core.alpm.remote import AUR, Official, OfficialSyncdb, Remote
@pytest.fixture

View File

@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.alpm.remote.aur import AUR
from ahriman.core.alpm.remote import AUR
from ahriman.core.exceptions import InvalidPackageInfo
from ahriman.models.aur_package import AURPackage
@ -131,7 +131,7 @@ def test_package_info(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman,
"""
must make request for info
"""
request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman])
request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman])
assert aur.package_info(aur_package_ahriman.name, pacman=pacman) == aur_package_ahriman
request_mock.assert_called_once_with("info", aur_package_ahriman.name)
@ -140,6 +140,6 @@ def test_package_search(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacma
"""
must make request for search
"""
request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman])
request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman])
assert aur.package_search(aur_package_ahriman.name, pacman=pacman) == [aur_package_ahriman]
request_mock.assert_called_once_with("search", aur_package_ahriman.name, by="name-desc")

View File

@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.alpm.remote.official import Official
from ahriman.core.alpm.remote import Official
from ahriman.core.exceptions import InvalidPackageInfo
from ahriman.models.aur_package import AURPackage
@ -111,7 +111,7 @@ def test_package_info(official: Official, aur_package_akonadi: AURPackage, pacma
"""
must make request for info
"""
request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request",
request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request",
return_value=[aur_package_akonadi])
assert official.package_info(aur_package_akonadi.name, pacman=pacman) == aur_package_akonadi
request_mock.assert_called_once_with(aur_package_akonadi.name, by="name")
@ -122,7 +122,7 @@ def test_package_search(official: Official, aur_package_akonadi: AURPackage, pac
"""
must make request for search
"""
request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request",
request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request",
return_value=[aur_package_akonadi])
assert official.package_search(aur_package_akonadi.name, pacman=pacman) == [aur_package_akonadi]
request_mock.assert_called_once_with(aur_package_akonadi.name, by="q")

View File

@ -1,7 +1,7 @@
from pytest_mock import MockerFixture
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb
from ahriman.core.alpm.remote import OfficialSyncdb
from ahriman.models.aur_package import AURPackage

View File

@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
from unittest import mock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.alpm.remote.remote import Remote
from ahriman.core.alpm.remote import Remote
from ahriman.models.aur_package import AURPackage
@ -12,7 +12,7 @@ def test_info(pacman: Pacman, mocker: MockerFixture) -> None:
"""
must call info method
"""
info_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_info")
info_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_info")
Remote.info("ahriman", pacman=pacman)
info_mock.assert_called_once_with("ahriman", pacman=pacman)
@ -22,7 +22,7 @@ def test_multisearch(aur_package_ahriman: AURPackage, pacman: Pacman, mocker: Mo
must search in AUR with multiple words
"""
terms = ["ahriman", "is", "cool"]
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman])
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman])
assert Remote.multisearch(*terms, pacman=pacman) == [aur_package_ahriman]
search_mock.assert_has_calls([mock.call("ahriman", pacman=pacman), mock.call("cool", pacman=pacman)])
@ -33,7 +33,7 @@ def test_multisearch_empty(pacman: Pacman, mocker: MockerFixture) -> None:
must return empty list if no long terms supplied
"""
terms = ["it", "is"]
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search")
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search")
assert Remote.multisearch(*terms, pacman=pacman) == []
search_mock.assert_not_called()
@ -43,7 +43,7 @@ def test_multisearch_single(aur_package_ahriman: AURPackage, pacman: Pacman, moc
"""
must search in AUR with one word
"""
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman])
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman])
assert Remote.multisearch("ahriman", pacman=pacman) == [aur_package_ahriman]
search_mock.assert_called_once_with("ahriman", pacman=pacman)
@ -68,7 +68,7 @@ def test_search(pacman: Pacman, mocker: MockerFixture) -> None:
"""
must call search method
"""
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_search")
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_search")
Remote.search("ahriman", pacman=pacman)
search_mock.assert_called_once_with("ahriman", pacman=pacman)

View File

@ -1,9 +1,8 @@
import pytest
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.auth import Mapping, OAuth
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
@pytest.fixture

View File

@ -1,8 +1,6 @@
from ahriman.core.auth.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.auth import Auth, Mapping, OAuth
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess

View File

@ -1,6 +1,6 @@
from pytest_mock import MockerFixture
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth import Mapping
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess
@ -11,7 +11,7 @@ async def test_check_credentials(mapping: Mapping, user: User, mocker: MockerFix
"""
current_password = user.password
user = user.hash_password(mapping.salt)
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert await mapping.check_credentials(user.username, current_password)
# here password is hashed so it is invalid
assert not await mapping.check_credentials(user.username, user.password)
@ -37,7 +37,7 @@ def test_get_user(mapping: Mapping, user: User, mocker: MockerFixture) -> None:
"""
must return user from storage by username
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert mapping.get_user(user.username) == user
@ -45,7 +45,7 @@ def test_get_user_normalized(mapping: Mapping, user: User, mocker: MockerFixture
"""
must return user from storage by username case-insensitive
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert mapping.get_user(user.username.upper()) == user
@ -60,7 +60,7 @@ async def test_known_username(mapping: Mapping, user: User, mocker: MockerFixtur
"""
must allow only known users
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert await mapping.known_username(user.username)
@ -69,7 +69,7 @@ async def test_known_username_unknown(mapping: Mapping, user: User, mocker: Mock
must not allow only known users
"""
assert not await mapping.known_username(None)
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=None)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=None)
assert not await mapping.known_username(user.password)
@ -77,6 +77,6 @@ async def test_verify_access(mapping: Mapping, user: User, mocker: MockerFixture
"""
must verify user access
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert await mapping.verify_access(user.username, user.access, None)
assert not await mapping.verify_access(user.username, UserAccess.Write, None)

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.auth.oauth import OAuth
from ahriman.core.auth import OAuth
from ahriman.core.exceptions import InvalidOption

View File

@ -2,7 +2,7 @@ from pathlib import Path
from pytest_mock import MockerFixture
from ahriman.core.build_tools.task import Task
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
def test_build(task_ahriman: Task, mocker: MockerFixture) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess

View File

@ -1,4 +1,4 @@
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.package import Package

View File

@ -3,7 +3,7 @@ import sqlite3
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
def test_factory(database: SQLite) -> None:

View File

@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
from sqlite3 import Connection
from unittest import mock
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.package import Package
from ahriman.models.package_source import PackageSource
@ -97,8 +97,8 @@ def test_package_remove(database: SQLite, package_ahriman: Package, mocker: Mock
"""
must totally remove package from the database
"""
remove_package_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_package_base")
remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages")
remove_package_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_package_base")
remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages")
database.package_remove(package_ahriman.base)
remove_package_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.base)
@ -110,10 +110,10 @@ def test_package_update(database: SQLite, package_ahriman: Package, mocker: Mock
must update package status
"""
status = BuildStatus()
insert_base_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_base")
insert_status_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_status")
insert_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_packages")
remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages")
insert_base_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_base")
insert_status_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_status")
insert_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_packages")
remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages")
database.package_update(package_ahriman, status)
insert_base_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman)
@ -127,10 +127,10 @@ def test_packages_get(database: SQLite, package_ahriman: Package, mocker: Mocker
"""
must return all packages
"""
select_bases_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_package_bases",
select_bases_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_package_bases",
return_value={package_ahriman.base: package_ahriman})
select_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_packages")
select_statuses_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_statuses")
select_packages_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_packages")
select_statuses_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_statuses")
database.packages_get()
select_bases_mock.assert_called_once_with(pytest.helpers.anyvar(int))

View File

@ -1,4 +1,4 @@
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.package import Package

View File

@ -3,14 +3,14 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
def test_load(configuration: Configuration, mocker: MockerFixture) -> None:
"""
must correctly load instance
"""
init_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.init")
init_mock = mocker.patch("ahriman.core.database.SQLite.init")
SQLite.load(configuration)
init_mock.assert_called_once_with(configuration)

View File

@ -1,12 +1,6 @@
import pytest
from ahriman.core.formatters.aur_printer import AurPrinter
from ahriman.core.formatters.configuration_printer import ConfigurationPrinter
from ahriman.core.formatters.package_printer import PackagePrinter
from ahriman.core.formatters.status_printer import StatusPrinter
from ahriman.core.formatters.string_printer import StringPrinter
from ahriman.core.formatters.update_printer import UpdatePrinter
from ahriman.core.formatters.user_printer import UserPrinter
from ahriman.core.formatters import AurPrinter, ConfigurationPrinter, PackagePrinter, StatusPrinter, StringPrinter, UpdatePrinter, UserPrinter
from ahriman.models.aur_package import AURPackage
from ahriman.models.build_status import BuildStatus
from ahriman.models.package import Package

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.aur_printer import AurPrinter
from ahriman.core.formatters import AurPrinter
def test_properties(aur_package_ahriman_printer: AurPrinter) -> None:

View File

@ -1,6 +1,6 @@
import pytest
from ahriman.core.formatters.build_printer import BuildPrinter
from ahriman.core.formatters import BuildPrinter
from ahriman.models.package import Package

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.configuration_printer import ConfigurationPrinter
from ahriman.core.formatters import ConfigurationPrinter
def test_properties(configuration_printer: ConfigurationPrinter) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.package_printer import PackagePrinter
from ahriman.core.formatters import PackagePrinter
def test_properties(package_ahriman_printer: PackagePrinter) -> None:

View File

@ -1,7 +1,7 @@
from unittest.mock import MagicMock
from ahriman.core.formatters.package_printer import PackagePrinter
from ahriman.core.formatters.printer import Printer
from ahriman.core.formatters import PackagePrinter
from ahriman.core.formatters import Printer
def test_print(package_ahriman_printer: PackagePrinter) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.status_printer import StatusPrinter
from ahriman.core.formatters import StatusPrinter
def test_properties(status_printer: StatusPrinter) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.string_printer import StringPrinter
from ahriman.core.formatters import StringPrinter
def test_properties(string_printer: StringPrinter) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.update_printer import UpdatePrinter
from ahriman.core.formatters import UpdatePrinter
def test_properties(update_printer: UpdatePrinter) -> None:

View File

@ -1,4 +1,4 @@
from ahriman.core.formatters.user_printer import UserPrinter
from ahriman.core.formatters import UserPrinter
def test_properties(user_printer: UserPrinter) -> None:

View File

@ -2,7 +2,7 @@ from pytest_mock import MockerFixture
from unittest import mock
from ahriman.core.configuration import Configuration
from ahriman.core.report.console import Console
from ahriman.core.report import Console
from ahriman.models.package import Package
from ahriman.models.result import Result
@ -12,7 +12,7 @@ def test_generate(configuration: Configuration, result: Result, package_python_s
"""
must print result to stdout
"""
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
result.add_failed(package_python_schedule)
report = Console("x86_64", configuration, "console")

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.report.email import Email
from ahriman.core.report import Email
from ahriman.models.package import Package
from ahriman.models.result import Result
@ -90,7 +90,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, mocker
"""
must generate report
"""
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
send_mock = mocker.patch("ahriman.core.report.Email._send")
report = Email("x86_64", configuration, "email")
report.generate([package_ahriman], Result())
@ -102,7 +102,7 @@ def test_generate_with_built(configuration: Configuration, package_ahriman: Pack
"""
must generate report with built packages
"""
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
send_mock = mocker.patch("ahriman.core.report.Email._send")
report = Email("x86_64", configuration, "email")
report.generate([package_ahriman], result)
@ -117,7 +117,7 @@ def test_generate_with_built_and_full_path(
"""
must generate report with built packages and full packages lists
"""
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
send_mock = mocker.patch("ahriman.core.report.Email._send")
report = Email("x86_64", configuration, "email")
report.full_template_path = report.template_path
@ -130,7 +130,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag
must not generate report with built packages if no_empty_report is set
"""
configuration.set_option("email", "no_empty_report", "yes")
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
send_mock = mocker.patch("ahriman.core.report.Email._send")
report = Email("x86_64", configuration, "email")
report.generate([package_ahriman], Result())
@ -143,7 +143,7 @@ def test_generate_no_empty_with_built(configuration: Configuration, package_ahri
must generate report with built packages if no_empty_report is set
"""
configuration.set_option("email", "no_empty_report", "yes")
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
send_mock = mocker.patch("ahriman.core.report.Email._send")
report = Email("x86_64", configuration, "email")
report.generate([package_ahriman], result)

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.report.html import HTML
from ahriman.core.report import HTML
from ahriman.models.package import Package

View File

@ -1,5 +1,5 @@
from ahriman.core.configuration import Configuration
from ahriman.core.report.jinja_template import JinjaTemplate
from ahriman.core.report import JinjaTemplate
from ahriman.models.package import Package
from ahriman.models.result import Result

View File

@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import ReportFailed
from ahriman.core.report.report import Report
from ahriman.core.report import Report
from ahriman.models.report_settings import ReportSettings
from ahriman.models.result import Result
@ -13,7 +13,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) ->
"""
must raise ReportFailed on errors
"""
mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception())
mocker.patch("ahriman.core.report.HTML.generate", side_effect=Exception())
with pytest.raises(ReportFailed):
Report.load("x86_64", configuration, "html").run([], Result())
@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, result: Result, mocker: Mock
must construct dummy report class
"""
mocker.patch("ahriman.models.report_settings.ReportSettings.from_option", return_value=ReportSettings.Disabled)
report_mock = mocker.patch("ahriman.core.report.report.Report.generate")
report_mock = mocker.patch("ahriman.core.report.Report.generate")
Report.load("x86_64", configuration, "disabled").run([], result)
report_mock.assert_called_once_with([], result)
@ -32,7 +32,7 @@ def test_report_console(configuration: Configuration, result: Result, mocker: Mo
"""
must generate console report
"""
report_mock = mocker.patch("ahriman.core.report.console.Console.generate")
report_mock = mocker.patch("ahriman.core.report.Console.generate")
Report.load("x86_64", configuration, "console").run([], result)
report_mock.assert_called_once_with([], result)
@ -41,7 +41,7 @@ def test_report_email(configuration: Configuration, result: Result, mocker: Mock
"""
must generate email report
"""
report_mock = mocker.patch("ahriman.core.report.email.Email.generate")
report_mock = mocker.patch("ahriman.core.report.Email.generate")
Report.load("x86_64", configuration, "email").run([], result)
report_mock.assert_called_once_with([], result)
@ -50,7 +50,7 @@ def test_report_html(configuration: Configuration, result: Result, mocker: Mocke
"""
must generate html report
"""
report_mock = mocker.patch("ahriman.core.report.html.HTML.generate")
report_mock = mocker.patch("ahriman.core.report.HTML.generate")
Report.load("x86_64", configuration, "html").run([], result)
report_mock.assert_called_once_with([], result)
@ -59,6 +59,6 @@ def test_report_telegram(configuration: Configuration, result: Result, mocker: M
"""
must generate telegram report
"""
report_mock = mocker.patch("ahriman.core.report.telegram.Telegram.generate")
report_mock = mocker.patch("ahriman.core.report.Telegram.generate")
Report.load("x86_64", configuration, "telegram").run([], result)
report_mock.assert_called_once_with([], result)

View File

@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
from unittest import mock
from ahriman.core.configuration import Configuration
from ahriman.core.report.telegram import Telegram
from ahriman.core.report import Telegram
from ahriman.models.package import Package
from ahriman.models.result import Result
@ -50,7 +50,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, result
"""
must generate report
"""
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
report = Telegram("x86_64", configuration, "telegram")
report.generate([package_ahriman], result)
@ -62,8 +62,8 @@ def test_generate_big_text(configuration: Configuration, package_ahriman: Packag
"""
must generate report with big text
"""
mocker.patch("ahriman.core.report.jinja_template.JinjaTemplate.make_html", return_value="a\n" * 4096)
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
mocker.patch("ahriman.core.report.JinjaTemplate.make_html", return_value="a\n" * 4096)
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
report = Telegram("x86_64", configuration, "telegram")
report.generate([package_ahriman], result)
@ -76,7 +76,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag
"""
must generate report
"""
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
report = Telegram("x86_64", configuration, "telegram")
report.generate([package_ahriman], Result())

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.repository import Repository
from ahriman.core.repository.cleaner import Cleaner
from ahriman.core.repository.executor import Executor

View File

@ -72,6 +72,6 @@ def test_clear_queue(cleaner: Cleaner, mocker: MockerFixture) -> None:
"""
must clear queued packages from the database
"""
clear_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear")
clear_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear")
cleaner.clear_queue()
clear_mock.assert_called_once_with(None)

View File

@ -5,9 +5,9 @@ from pytest_mock import MockerFixture
from unittest import mock
from unittest.mock import MagicMock
from ahriman.core.report.report import Report
from ahriman.core.report import Report
from ahriman.core.repository.executor import Executor
from ahriman.core.upload.upload import Upload
from ahriman.core.upload import Upload
from ahriman.models.package import Package
@ -64,8 +64,8 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
tree_clear_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_clear")
repo_remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear")
patches_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove")
build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear")
patches_mock = mocker.patch("ahriman.core.database.SQLite.patches_remove")
status_client_mock = mocker.patch("ahriman.core.status.client.Client.remove")
executor.process_remove([package_ahriman.base])
@ -150,8 +150,8 @@ def test_process_report(executor: Executor, package_ahriman: Package, mocker: Mo
must process report
"""
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
mocker.patch("ahriman.core.report.report.Report.load", return_value=Report("x86_64", executor.configuration))
report_mock = mocker.patch("ahriman.core.report.report.Report.run")
mocker.patch("ahriman.core.report.Report.load", return_value=Report("x86_64", executor.configuration))
report_mock = mocker.patch("ahriman.core.report.Report.run")
executor.process_report(["dummy"], [])
report_mock.assert_called_once_with([package_ahriman], [])
@ -170,8 +170,8 @@ def test_process_upload(executor: Executor, mocker: MockerFixture) -> None:
"""
must process sync
"""
mocker.patch("ahriman.core.upload.upload.Upload.load", return_value=Upload("x86_64", executor.configuration))
upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.run")
mocker.patch("ahriman.core.upload.Upload.load", return_value=Upload("x86_64", executor.configuration))
upload_mock = mocker.patch("ahriman.core.upload.Upload.run")
executor.process_sync(["dummy"], [])
upload_mock.assert_called_once_with(executor.paths.repository, [])

View File

@ -1,7 +1,7 @@
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.exceptions import UnsafeRun
from ahriman.core.repository.repository_properties import RepositoryProperties
from ahriman.core.status.web_client import WebClient

View File

@ -190,7 +190,7 @@ def test_updates_manual_status_known(update_handler: UpdateHandler, package_ahri
"""
must create record for known package via reporter
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman])
mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman])
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
@ -203,7 +203,7 @@ def test_updates_manual_status_unknown(update_handler: UpdateHandler, package_ah
"""
must create record for unknown package via reporter
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman])
mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman])
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[])
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_unknown")
@ -216,6 +216,6 @@ def test_updates_manual_with_failures(update_handler: UpdateHandler, package_ahr
"""
must process manual through the packages with failure
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", side_effect=Exception())
mocker.patch("ahriman.core.database.SQLite.build_queue_get", side_effect=Exception())
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
assert update_handler.updates_manual() == []

View File

@ -1,12 +1,9 @@
import pytest
import tempfile
from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import PropertyMock
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.exceptions import UnknownPackage
from ahriman.core.status.watcher import Watcher
from ahriman.core.status.web_client import WebClient
@ -51,7 +48,7 @@ def test_load(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture)
must correctly load packages
"""
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get")
cache_mock = mocker.patch("ahriman.core.database.SQLite.packages_get")
watcher.load()
cache_mock.assert_called_once_with()
@ -66,7 +63,7 @@ def test_load_known(watcher: Watcher, package_ahriman: Package, mocker: MockerFi
"""
status = BuildStatus(BuildStatusEnum.Success)
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get", return_value=[(package_ahriman, status)])
mocker.patch("ahriman.core.database.SQLite.packages_get", return_value=[(package_ahriman, status)])
watcher.known = {package_ahriman.base: (package_ahriman, status)}
watcher.load()
@ -78,7 +75,7 @@ def test_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur
"""
must remove package base
"""
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove")
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove")
watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())}
watcher.remove(package_ahriman.base)
@ -90,7 +87,7 @@ def test_remove_unknown(watcher: Watcher, package_ahriman: Package, mocker: Mock
"""
must not fail on unknown base removal
"""
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove")
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove")
watcher.remove(package_ahriman.base)
cache_mock.assert_called_once_with(package_ahriman.base)
@ -100,7 +97,7 @@ def test_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur
"""
must update package status
"""
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update")
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update")
watcher.update(package_ahriman.base, BuildStatusEnum.Unknown, package_ahriman)
cache_mock.assert_called_once_with(package_ahriman, pytest.helpers.anyvar(int))
@ -113,7 +110,7 @@ def test_update_ping(watcher: Watcher, package_ahriman: Package, mocker: MockerF
"""
must update package status only for known package
"""
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update")
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update")
watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())}
watcher.update(package_ahriman.base, BuildStatusEnum.Success, None)

View File

@ -2,7 +2,7 @@ import pytest
from pytest_mock import MockerFixture
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.tree import Leaf, Tree
from ahriman.models.package import Package

View File

@ -5,9 +5,7 @@ from typing import Any, Dict, List
from unittest.mock import MagicMock
from ahriman.core.configuration import Configuration
from ahriman.core.upload.github import Github
from ahriman.core.upload.rsync import Rsync
from ahriman.core.upload.s3 import S3
from ahriman.core.upload import Github, Rsync, S3
_s3_object = namedtuple("s3_object", ["key", "e_tag", "delete"])

View File

@ -6,14 +6,14 @@ from pytest_mock import MockerFixture
from typing import Any, Dict
from unittest import mock
from ahriman.core.upload.github import Github
from ahriman.core.upload import Github
def test_asset_remove(github: Github, github_release: Dict[str, Any], mocker: MockerFixture) -> None:
"""
must remove asset from the release
"""
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.asset_remove(github_release, "asset_name")
request_mock.assert_called_once_with("DELETE", "asset_url")
@ -22,7 +22,7 @@ def test_asset_remove_unknown(github: Github, github_release: Dict[str, Any], mo
"""
must not fail if no asset found
"""
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.asset_remove(github_release, "unknown_asset_name")
request_mock.assert_not_called()
@ -32,8 +32,8 @@ def test_asset_upload(github: Github, github_release: Dict[str, Any], mocker: Mo
must upload asset to the repository
"""
mocker.patch("pathlib.Path.open", return_value=b"")
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
github.asset_upload(github_release, Path("/root/new.tar.xz"))
request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"},
@ -46,8 +46,8 @@ def test_asset_upload_with_removal(github: Github, github_release: Dict[str, Any
must remove existing file before upload
"""
mocker.patch("pathlib.Path.open", return_value=b"")
mocker.patch("ahriman.core.upload.github.Github._request")
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
mocker.patch("ahriman.core.upload.Github._request")
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
github.asset_upload(github_release, Path("asset_name"))
github.asset_upload(github_release, Path("/root/asset_name"))
@ -62,9 +62,9 @@ def test_asset_upload_empty_mimetype(github: Github, github_release: Dict[str, A
must upload asset to the repository with empty mime type if cannot guess it
"""
mocker.patch("pathlib.Path.open", return_value=b"")
mocker.patch("ahriman.core.upload.github.Github.asset_remove")
mocker.patch("ahriman.core.upload.Github.asset_remove")
mocker.patch("mimetypes.guess_type", return_value=(None, None))
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.asset_upload(github_release, Path("/root/new.tar.xz"))
request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"},
@ -84,7 +84,7 @@ def test_files_remove(github: Github, github_release: Dict[str, Any], mocker: Mo
"""
must remove files from the remote
"""
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
github.files_remove(github_release, {Path("a"): "a"}, {"a": "a", "b": "b"})
remove_mock.assert_called_once_with(github_release, "b")
@ -93,7 +93,7 @@ def test_files_remove_empty(github: Github, github_release: Dict[str, Any], mock
"""
must remove nothing if nothing changed
"""
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
github.files_remove(github_release, {Path("a"): "a"}, {"a": "a"})
remove_mock.assert_not_called()
@ -102,7 +102,7 @@ def test_files_upload(github: Github, github_release: Dict[str, Any], mocker: Mo
"""
must upload files to the remote
"""
upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload")
upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload")
github.files_upload(github_release, {Path("a"): "a", Path("b"): "c", Path("c"): "c"}, {"a": "a", "b": "b"})
upload_mock.assert_has_calls([
mock.call(github_release, Path("b")),
@ -114,7 +114,7 @@ def test_files_upload_empty(github: Github, github_release: Dict[str, Any], mock
"""
must upload nothing if nothing changed
"""
upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload")
upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload")
github.files_upload(github_release, {Path("a"): "a"}, {"a": "a"})
upload_mock.assert_not_called()
@ -123,7 +123,7 @@ def test_release_create(github: Github, mocker: MockerFixture) -> None:
"""
must create release
"""
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.release_create()
request_mock.assert_called_once_with("POST", pytest.helpers.anyvar(str, True),
json={"tag_name": github.architecture, "name": github.architecture})
@ -133,7 +133,7 @@ def test_release_get(github: Github, mocker: MockerFixture) -> None:
"""
must get release
"""
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.release_get()
request_mock.assert_called_once_with("GET", pytest.helpers.anyvar(str, True))
@ -144,7 +144,7 @@ def test_release_get_empty(github: Github, mocker: MockerFixture) -> None:
"""
response = requests.Response()
response.status_code = 404
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=requests.HTTPError(response=response))
mocker.patch("ahriman.core.upload.Github._request", side_effect=requests.HTTPError(response=response))
assert github.release_get() is None
@ -152,7 +152,7 @@ def test_release_get_exception(github: Github, mocker: MockerFixture) -> None:
"""
must re-raise non HTTPError exception
"""
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=Exception())
mocker.patch("ahriman.core.upload.Github._request", side_effect=Exception())
with pytest.raises(Exception):
github.release_get()
@ -162,7 +162,7 @@ def test_release_get_exception_http_error(github: Github, mocker: MockerFixture)
must re-raise HTTPError exception with code differs from 404
"""
exception = requests.HTTPError(response=requests.Response())
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=exception)
mocker.patch("ahriman.core.upload.Github._request", side_effect=exception)
with pytest.raises(requests.HTTPError):
github.release_get()
@ -171,7 +171,7 @@ def test_release_update(github: Github, github_release: Dict[str, Any], mocker:
"""
must update release
"""
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
request_mock = mocker.patch("ahriman.core.upload.Github._request")
github.release_update(github_release, "body")
request_mock.assert_called_once_with("POST", "release_url", json={"body": "body"})
@ -180,12 +180,12 @@ def test_release_sync(github: Github, mocker: MockerFixture) -> None:
"""
must run sync command
"""
release_get_mock = mocker.patch("ahriman.core.upload.github.Github.release_get", return_value={})
get_hashes_mock = mocker.patch("ahriman.core.upload.github.Github.get_hashes", return_value={})
get_local_files_mock = mocker.patch("ahriman.core.upload.github.Github.get_local_files", return_value={})
files_upload_mock = mocker.patch("ahriman.core.upload.github.Github.files_upload")
files_remove_mock = mocker.patch("ahriman.core.upload.github.Github.files_remove")
release_update_mock = mocker.patch("ahriman.core.upload.github.Github.release_update")
release_get_mock = mocker.patch("ahriman.core.upload.Github.release_get", return_value={})
get_hashes_mock = mocker.patch("ahriman.core.upload.Github.get_hashes", return_value={})
get_local_files_mock = mocker.patch("ahriman.core.upload.Github.get_local_files", return_value={})
files_upload_mock = mocker.patch("ahriman.core.upload.Github.files_upload")
files_remove_mock = mocker.patch("ahriman.core.upload.Github.files_remove")
release_update_mock = mocker.patch("ahriman.core.upload.Github.release_update")
github.sync(Path("local"), [])
release_get_mock.assert_called_once_with()
@ -200,13 +200,13 @@ def test_release_sync_create_release(github: Github, mocker: MockerFixture) -> N
"""
must create release in case if it does not exist
"""
mocker.patch("ahriman.core.upload.github.Github.release_get", return_value=None)
mocker.patch("ahriman.core.upload.github.Github.get_hashes")
mocker.patch("ahriman.core.upload.github.Github.get_local_files")
mocker.patch("ahriman.core.upload.github.Github.files_upload")
mocker.patch("ahriman.core.upload.github.Github.files_remove")
mocker.patch("ahriman.core.upload.github.Github.release_update")
release_create_mock = mocker.patch("ahriman.core.upload.github.Github.release_create")
mocker.patch("ahriman.core.upload.Github.release_get", return_value=None)
mocker.patch("ahriman.core.upload.Github.get_hashes")
mocker.patch("ahriman.core.upload.Github.get_local_files")
mocker.patch("ahriman.core.upload.Github.files_upload")
mocker.patch("ahriman.core.upload.Github.files_remove")
mocker.patch("ahriman.core.upload.Github.release_update")
release_create_mock = mocker.patch("ahriman.core.upload.Github.release_create")
github.sync(Path("local"), [])
release_create_mock.assert_called_once_with()

View File

@ -5,8 +5,7 @@ from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.upload.github import Github
from ahriman.core.upload.http_upload import HttpUpload
from ahriman.core.upload import Github, HttpUpload
def test_calculate_hash_empty(resource_path_root: Path) -> None:

View File

@ -1,13 +1,13 @@
from pathlib import Path
from pytest_mock import MockerFixture
from ahriman.core.upload.rsync import Rsync
from ahriman.core.upload import Rsync
def test_sync(rsync: Rsync, mocker: MockerFixture) -> None:
"""
must run sync command
"""
check_output_mock = mocker.patch("ahriman.core.upload.rsync.Rsync._check_output")
check_output_mock = mocker.patch("ahriman.core.upload.Rsync._check_output")
rsync.sync(Path("path"), [])
check_output_mock.assert_called_once_with(*rsync.command, "path", rsync.remote, exception=None, logger=rsync.logger)

View File

@ -1,12 +1,10 @@
import pytest
from pathlib import Path
from pytest_mock import MockerFixture
from typing import Any, List, Optional, Tuple
from unittest import mock
from unittest.mock import MagicMock
from ahriman.core.upload.s3 import S3
from ahriman.core.upload import S3
_chunk_size = 8 * 1024 * 1024
@ -106,10 +104,10 @@ def test_sync(s3: S3, mocker: MockerFixture) -> None:
"""
must run sync command
"""
local_files_mock = mocker.patch("ahriman.core.upload.s3.S3.get_local_files", return_value=["a"])
remote_objects_mock = mocker.patch("ahriman.core.upload.s3.S3.get_remote_objects", return_value=["b"])
remove_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_remove")
upload_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_upload")
local_files_mock = mocker.patch("ahriman.core.upload.S3.get_local_files", return_value=["a"])
remote_objects_mock = mocker.patch("ahriman.core.upload.S3.get_remote_objects", return_value=["b"])
remove_files_mock = mocker.patch("ahriman.core.upload.S3.files_remove")
upload_files_mock = mocker.patch("ahriman.core.upload.S3.files_upload")
s3.sync(Path("root"), [])
remote_objects_mock.assert_called_once_with()

View File

@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import SyncFailed
from ahriman.core.upload.upload import Upload
from ahriman.core.upload import Upload
from ahriman.models.upload_settings import UploadSettings
@ -13,7 +13,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) ->
"""
must raise SyncFailed on errors
"""
mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception())
mocker.patch("ahriman.core.upload.Rsync.sync", side_effect=Exception())
with pytest.raises(SyncFailed):
Upload.load("x86_64", configuration, "rsync").run(Path("path"), [])
@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, mocker: MockerFixture) -> No
must construct dummy upload class
"""
mocker.patch("ahriman.models.upload_settings.UploadSettings.from_option", return_value=UploadSettings.Disabled)
upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.sync")
upload_mock = mocker.patch("ahriman.core.upload.Upload.sync")
Upload.load("x86_64", configuration, "disabled").run(Path("path"), [])
upload_mock.assert_called_once_with(Path("path"), [])
@ -32,7 +32,7 @@ def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> No
"""
must upload via rsync
"""
upload_mock = mocker.patch("ahriman.core.upload.rsync.Rsync.sync")
upload_mock = mocker.patch("ahriman.core.upload.Rsync.sync")
Upload.load("x86_64", configuration, "rsync").run(Path("path"), [])
upload_mock.assert_called_once_with(Path("path"), [])
@ -41,7 +41,7 @@ def test_upload_s3(configuration: Configuration, mocker: MockerFixture) -> None:
"""
must upload via s3
"""
upload_mock = mocker.patch("ahriman.core.upload.s3.S3.sync")
upload_mock = mocker.patch("ahriman.core.upload.S3.sync")
Upload.load("x86_64", configuration, "customs3").run(Path("path"), [])
upload_mock.assert_called_once_with(Path("path"), [])
@ -50,6 +50,6 @@ def test_upload_github(configuration: Configuration, mocker: MockerFixture) -> N
"""
must upload via github
"""
upload_mock = mocker.patch("ahriman.core.upload.github.Github.sync")
upload_mock = mocker.patch("ahriman.core.upload.Github.sync")
Upload.load("x86_64", configuration, "github").run(Path("path"), [])
upload_mock.assert_called_once_with(Path("path"), [])

View File

@ -85,7 +85,7 @@ def test_from_aur(package_ahriman: Package, aur_package_ahriman: AURPackage, pac
"""
must construct package from aur
"""
mocker.patch("ahriman.core.alpm.remote.aur.AUR.info", return_value=aur_package_ahriman)
mocker.patch("ahriman.core.alpm.remote.AUR.info", return_value=aur_package_ahriman)
package = Package.from_aur(package_ahriman.base, pacman)
assert package_ahriman.base == package.base
@ -144,7 +144,7 @@ def test_from_official(package_ahriman: Package, aur_package_ahriman: AURPackage
"""
must construct package from official repository
"""
mocker.patch("ahriman.core.alpm.remote.official.Official.info", return_value=aur_package_ahriman)
mocker.patch("ahriman.core.alpm.remote.Official.info", return_value=aur_package_ahriman)
package = Package.from_official(package_ahriman.base, pacman)
assert package_ahriman.base == package.base

View File

@ -46,8 +46,8 @@ def test_from_source_aur(package_ahriman: Package, mocker: MockerFixture) -> Non
"""
must construct remote from AUR source
"""
remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.remote_git_url")
remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.remote_web_url")
remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.AUR.remote_git_url")
remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.AUR.remote_web_url")
remote = RemoteSource.from_source(PackageSource.AUR, package_ahriman.base, "aur")
remote_git_url_mock.assert_called_once_with(package_ahriman.base, "aur")
@ -61,8 +61,8 @@ def test_from_source_official(package_ahriman: Package, mocker: MockerFixture) -
"""
must construct remote from official repository source
"""
remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.remote_git_url")
remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.remote_web_url")
remote_git_url_mock = mocker.patch("ahriman.core.alpm.remote.Official.remote_git_url")
remote_web_url_mock = mocker.patch("ahriman.core.alpm.remote.Official.remote_web_url")
remote = RemoteSource.from_source(PackageSource.Repository, package_ahriman.base, "community")
remote_git_url_mock.assert_called_once_with(package_ahriman.base, "community")

View File

@ -8,7 +8,7 @@ from typing import Any
import ahriman.core.auth.helpers
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.core.spawn import Spawn
from ahriman.models.user import User
from ahriman.web.web import setup_service
@ -50,7 +50,7 @@ def application(configuration: Configuration, spawner: Spawn, database: SQLite,
Returns:
web.Application: application test instance
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", False)
return setup_service("x86_64", configuration, spawner)
@ -73,13 +73,13 @@ def application_with_auth(configuration: Configuration, user: User, spawner: Spa
web.Application: application test instance
"""
configuration.set_option("auth", "target", "configuration")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", True)
application = setup_service("x86_64", configuration, spawner)
generated = user.hash_password(application["validator"].salt)
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=generated)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=generated)
return application
@ -101,7 +101,7 @@ def application_with_debug(configuration: Configuration, user: User, spawner: Sp
web.Application: application test instance
"""
configuration.set_option("web", "debug", "yes")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", False)
return setup_service("x86_64", configuration, spawner)

View File

@ -1,8 +1,8 @@
import pytest
from ahriman.core.auth.auth import Auth
from ahriman.core.auth import Auth
from ahriman.core.configuration import Configuration
from ahriman.core.database.sqlite import SQLite
from ahriman.core.database import SQLite
from ahriman.models.user import User
from ahriman.web.middlewares.auth_handler import AuthorizationPolicy

View File

@ -4,7 +4,7 @@ from aiohttp import web
from pytest_mock import MockerFixture
from unittest.mock import AsyncMock
from ahriman.core.auth.auth import Auth
from ahriman.core.auth import Auth
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess
from ahriman.models.user_identity import UserIdentity
@ -28,7 +28,7 @@ async def test_authorized_userid(authorization_policy: AuthorizationPolicy, user
"""
must return authorized user id
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
assert await authorization_policy.authorized_userid(_identity(user.username)) == user.username

View File

@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
from typing import Any
from unittest.mock import MagicMock
from ahriman.core.auth.oauth import OAuth
from ahriman.core.auth import OAuth
from ahriman.web.views.base import BaseView

View File

@ -21,7 +21,7 @@ async def test_get(client: TestClient, aur_package_ahriman: AURPackage, mocker:
"""
must call get request correctly
"""
mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[aur_package_ahriman])
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
response = await client.get("/service-api/v1/search", params={"for": "ahriman"})
assert response.ok
@ -33,7 +33,7 @@ async def test_get_exception(client: TestClient, mocker: MockerFixture) -> None:
"""
must raise 400 on empty search string
"""
search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch", return_value=[])
search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[])
response = await client.get("/service-api/v1/search")
assert response.status == 404
@ -44,7 +44,7 @@ async def test_get_join(client: TestClient, mocker: MockerFixture) -> None:
"""
must join search args with space
"""
search_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.multisearch")
search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch")
response = await client.get("/service-api/v1/search", params=[("for", "ahriman"), ("for", "maybe")])
assert response.ok

View File

@ -2,9 +2,7 @@ import pytest
from aiohttp.test_utils import TestClient
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.auth.oauth import OAuth
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess
from ahriman.web.views.user.login import LoginView