mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-30 18:27:18 +00:00
update tests
This commit is contained in:
parent
6612510d12
commit
1a8d3efaf1
@ -116,7 +116,7 @@ class Handler:
|
||||
args(argparse.Namespace): command line args
|
||||
|
||||
Returns:
|
||||
tuple[str | None, str]: list of repository names and architectures for which tree is created
|
||||
list[RepositoryId]: list of repository names and architectures for which tree is created
|
||||
|
||||
Raises:
|
||||
MissingArchitectureError: if no architecture set and automatic detection is not allowed or failed
|
||||
|
@ -66,8 +66,8 @@ class Setup(Handler):
|
||||
Setup.configuration_create_makepkg(args.packager, args.makeflags_jobs, application.repository.paths)
|
||||
Setup.executable_create(application.repository.paths, repository_id)
|
||||
repository_server = f"file://{application.repository.paths.repository}" if args.server is None else args.server
|
||||
Setup.configuration_create_devtools(repository_id, args.from_configuration, args.mirror, args.multilib,
|
||||
repository_server)
|
||||
Setup.configuration_create_devtools(
|
||||
repository_id, args.from_configuration, args.mirror, args.multilib, repository_server)
|
||||
Setup.configuration_create_sudo(application.repository.paths, repository_id)
|
||||
|
||||
application.repository.repo.init()
|
||||
|
@ -77,8 +77,7 @@ class Web(Handler):
|
||||
"""
|
||||
# read architecture from the same argument list
|
||||
yield from ["--architecture", repository_id.architecture]
|
||||
if repository_id.name is not None:
|
||||
yield from ["--repository", repository_id.name]
|
||||
yield from ["--repository", repository_id.name]
|
||||
# read configuration path from current settings
|
||||
if (configuration_path := configuration.path) is not None:
|
||||
yield from ["--configuration", str(configuration_path)]
|
||||
|
@ -6,3 +6,10 @@ def test_create_tree(application_properties: ApplicationProperties) -> None:
|
||||
must have repository attribute
|
||||
"""
|
||||
assert application_properties.repository
|
||||
|
||||
|
||||
def test_architecture(application_properties: ApplicationProperties) -> None:
|
||||
"""
|
||||
must return repository architecture
|
||||
"""
|
||||
assert application_properties.architecture == application_properties.repository_id.architecture
|
||||
|
@ -8,48 +8,7 @@ from ahriman.application.handlers import Handler
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import ExitCode, MissingArchitectureError, MultipleArchitecturesError
|
||||
from ahriman.models.log_handler import LogHandler
|
||||
|
||||
|
||||
def test_architectures_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate list of available architectures
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
|
||||
Handler.architectures_extract(args)
|
||||
known_architectures_mock.assert_called_once_with(configuration.getpath("repository", "root"))
|
||||
|
||||
|
||||
def test_architectures_extract_empty(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception if no available architectures found
|
||||
"""
|
||||
args.command = "config"
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
||||
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.architectures_extract(args)
|
||||
|
||||
|
||||
def test_architectures_extract_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception on missing architectures
|
||||
"""
|
||||
args.command = "config"
|
||||
mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.architectures_extract(args)
|
||||
|
||||
|
||||
def test_architectures_extract_specified(args: argparse.Namespace) -> None:
|
||||
"""
|
||||
must return architecture list if it has been specified
|
||||
"""
|
||||
architectures = args.architecture = ["i686", "x86_64"]
|
||||
assert Handler.architectures_extract(args) == sorted(set(architectures))
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
def test_call(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -62,20 +21,21 @@ def test_call(args: argparse.Namespace, configuration: Configuration, mocker: Mo
|
||||
args.report = False
|
||||
mocker.patch("ahriman.application.handlers.Handler.run")
|
||||
configuration_mock = mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||
log_handler_mock = mocker.patch("ahriman.core.log.Log.handler", return_value=args.log_handler)
|
||||
log_load_mock = mocker.patch("ahriman.core.log.Log.load")
|
||||
log_handler_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.handler", return_value=args.log_handler)
|
||||
log_load_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.load")
|
||||
enter_mock = mocker.patch("ahriman.application.lock.Lock.__enter__")
|
||||
exit_mock = mocker.patch("ahriman.application.lock.Lock.__exit__")
|
||||
|
||||
assert Handler.call(args, "x86_64")
|
||||
configuration_mock.assert_called_once_with(args.configuration, "x86_64")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert Handler.call(args, repository_id)
|
||||
configuration_mock.assert_called_once_with(args.configuration, repository_id)
|
||||
log_handler_mock.assert_called_once_with(args.log_handler)
|
||||
log_load_mock.assert_called_once_with(configuration, args.log_handler, quiet=args.quiet, report=args.report)
|
||||
enter_mock.assert_called_once_with()
|
||||
exit_mock.assert_called_once_with(None, None, None)
|
||||
|
||||
|
||||
def test_call_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_call_exception(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process exception
|
||||
"""
|
||||
@ -84,11 +44,12 @@ def test_call_exception(args: argparse.Namespace, mocker: MockerFixture) -> None
|
||||
mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=Exception())
|
||||
logging_mock = mocker.patch("logging.Logger.exception")
|
||||
|
||||
assert not Handler.call(args, "x86_64")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert not Handler.call(args, repository_id)
|
||||
logging_mock.assert_called_once_with(pytest.helpers.anyvar(str, strict=True))
|
||||
|
||||
|
||||
def test_call_exit_code(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_call_exit_code(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process exitcode exception
|
||||
"""
|
||||
@ -97,7 +58,8 @@ def test_call_exit_code(args: argparse.Namespace, mocker: MockerFixture) -> None
|
||||
mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=ExitCode())
|
||||
logging_mock = mocker.patch("logging.Logger.exception")
|
||||
|
||||
assert not Handler.call(args, "x86_64")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert not Handler.call(args, repository_id)
|
||||
logging_mock.assert_not_called()
|
||||
|
||||
|
||||
@ -105,33 +67,39 @@ def test_execute(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run execution in multiple processes
|
||||
"""
|
||||
args.architecture = ["i686", "x86_64"]
|
||||
ids = [
|
||||
RepositoryId("i686", "aur-clone"),
|
||||
RepositoryId("x86_64", "aur-clone"),
|
||||
]
|
||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=ids)
|
||||
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
||||
|
||||
Handler.execute(args)
|
||||
starmap_mock.assert_called_once_with(Handler.call, [(args, architecture) for architecture in args.architecture])
|
||||
starmap_mock.assert_called_once_with(Handler.call, [(args, repository_id) for repository_id in ids])
|
||||
|
||||
|
||||
def test_execute_multiple_not_supported(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise an exception if multiple architectures are not supported by the handler
|
||||
"""
|
||||
args.architecture = ["i686", "x86_64"]
|
||||
args.command = "web"
|
||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[
|
||||
RepositoryId("i686", "aur-clone"),
|
||||
RepositoryId("x86_64", "aur-clone"),
|
||||
])
|
||||
mocker.patch.object(Handler, "ALLOW_MULTI_ARCHITECTURE_RUN", False)
|
||||
|
||||
with pytest.raises(MultipleArchitecturesError):
|
||||
Handler.execute(args)
|
||||
|
||||
|
||||
def test_execute_single(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
def test_execute_single(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run execution in current process if only one architecture supplied
|
||||
"""
|
||||
args.architecture = ["x86_64"]
|
||||
args.configuration = Path("")
|
||||
args.quiet = False
|
||||
mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[
|
||||
RepositoryId("x86_64", "aur-clone"),
|
||||
])
|
||||
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
||||
|
||||
Handler.execute(args)
|
||||
@ -142,8 +110,73 @@ def test_run(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing method
|
||||
"""
|
||||
_, repository_id = configuration.check_loaded()
|
||||
with pytest.raises(NotImplementedError):
|
||||
Handler.run(args, "x86_64", configuration, report=True)
|
||||
Handler.run(args, repository_id, configuration, report=True)
|
||||
|
||||
|
||||
def test_repositories_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate list of available architectures
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
_, repository_id = configuration.check_loaded()
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
|
||||
Handler.repositories_extract(args)
|
||||
known_architectures_mock.assert_called_once_with(configuration.getpath("repository", "root"), repository_id.name)
|
||||
|
||||
|
||||
def test_repositories_extract_empty(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception if no available architectures found
|
||||
"""
|
||||
args.command = "config"
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
||||
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.repositories_extract(args)
|
||||
|
||||
|
||||
def test_repositories_extract_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception on missing architectures
|
||||
"""
|
||||
args.command = "config"
|
||||
mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.repositories_extract(args)
|
||||
|
||||
|
||||
def test_repositories_extract_specified(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
"""
|
||||
must return architecture list if it has been specified
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.architecture = ["i686", "x86_64"]
|
||||
args.repository = []
|
||||
_, repository_id = configuration.check_loaded()
|
||||
|
||||
ids = [RepositoryId(architecture, repository_id.name) for architecture in args.architecture]
|
||||
assert Handler.repositories_extract(args) == sorted(set(ids))
|
||||
|
||||
|
||||
def test_repositories_extract_specified_with_repository(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
"""
|
||||
must return architecture list if it has been specified together with repositories
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.architecture = ["i686", "x86_64"]
|
||||
args.repository = ["repo1", "repo2"]
|
||||
|
||||
ids = [
|
||||
RepositoryId(architecture, name)
|
||||
for architecture in args.architecture
|
||||
for name in args.repository
|
||||
]
|
||||
assert Handler.repositories_extract(args) == sorted(set(ids))
|
||||
|
||||
|
||||
def test_check_if_empty() -> None:
|
||||
|
@ -44,7 +44,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Add.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Add.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(args.package, args.source, args.username)
|
||||
dependencies_mock.assert_not_called()
|
||||
on_start_mock.assert_called_once_with()
|
||||
@ -68,7 +69,8 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
|
||||
return_value=[package_ahriman])
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
Add.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Add.run(args, repository_id, configuration, report=False)
|
||||
updates_mock.assert_called_once_with(args.package, aur=False, local=False, manual=True, vcs=False)
|
||||
application_mock.assert_called_once_with([package_ahriman],
|
||||
Packagers(args.username, {package_ahriman.base: "packager"}),
|
||||
@ -94,5 +96,6 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Add.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Add.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
@ -33,7 +33,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
add_mock = tarfile.__enter__.return_value = MagicMock()
|
||||
mocker.patch("tarfile.TarFile.__new__", return_value=tarfile)
|
||||
|
||||
Backup.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Backup.run(args, repository_id, configuration, report=False)
|
||||
add_mock.add.assert_called_once_with(Path("path"))
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.clean")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Clean.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Clean.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(cache=False, chroot=False, manual=False, packages=False, pacman=False)
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
@ -33,7 +33,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
start_mock = mocker.patch("threading.Timer.start")
|
||||
join_mock = mocker.patch("threading.Timer.join")
|
||||
|
||||
Daemon.run(args, "x86_64", configuration, report=True)
|
||||
run_mock.assert_called_once_with(args, "x86_64", configuration, report=True)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Daemon.run(args, repository_id, configuration, report=True)
|
||||
run_mock.assert_called_once_with(args, repository_id, configuration, report=True)
|
||||
start_mock.assert_called_once_with()
|
||||
join_mock.assert_called_once_with()
|
||||
|
@ -29,7 +29,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump",
|
||||
return_value=configuration.dump())
|
||||
|
||||
Dump.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Dump.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with()
|
||||
print_mock.assert_called()
|
||||
|
||||
|
@ -29,7 +29,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
args = _default_args(args)
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Help.run(args, repository_id, configuration, report=False)
|
||||
parse_mock.assert_called_once_with(["--help"])
|
||||
|
||||
|
||||
@ -41,7 +42,8 @@ def test_run_command(args: argparse.Namespace, configuration: Configuration, moc
|
||||
args.command = "aur-search"
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Help.run(args, repository_id, configuration, report=False)
|
||||
parse_mock.assert_called_once_with(["aur-search", "--help"])
|
||||
|
||||
|
||||
|
@ -31,7 +31,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_import")
|
||||
|
||||
KeyImport.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
KeyImport.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(args.key_server, args.key)
|
||||
|
||||
|
||||
|
@ -44,8 +44,9 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
return_value=(args.package, PkgbuildPatch(None, "patch")))
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, report=False)
|
||||
patch_mock.assert_called_once_with(args.package, "x86_64", args.track)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Patch.run(args, repository_id, configuration, report=False)
|
||||
patch_mock.assert_called_once_with(args.package, repository_id.architecture, args.track)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, PkgbuildPatch(None, "patch"))
|
||||
|
||||
|
||||
@ -63,7 +64,8 @@ def test_run_function(args: argparse.Namespace, configuration: Configuration, re
|
||||
patch_mock = mocker.patch("ahriman.application.handlers.Patch.patch_create_from_function", return_value=patch)
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Patch.run(args, repository_id, configuration, report=False)
|
||||
patch_mock.assert_called_once_with(args.variable, args.patch)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, patch)
|
||||
|
||||
@ -79,7 +81,8 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, reposi
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Patch.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"], False)
|
||||
|
||||
|
||||
@ -94,11 +97,12 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Patch.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"])
|
||||
|
||||
|
||||
def test_patch_create_from_diff(package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
def test_patch_create_from_diff(package_ahriman: Package, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create patch from directory tree diff
|
||||
"""
|
||||
@ -108,8 +112,9 @@ def test_patch_create_from_diff(package_ahriman: Package, mocker: MockerFixture)
|
||||
package_mock = mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
|
||||
sources_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create", return_value=patch.value)
|
||||
|
||||
assert Patch.patch_create_from_diff(path, "x86_64", ["*.diff"]) == (package_ahriman.base, patch)
|
||||
package_mock.assert_called_once_with(path, "x86_64", None)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert Patch.patch_create_from_diff(path, repository_id.architecture, ["*.diff"]) == (package_ahriman.base, patch)
|
||||
package_mock.assert_called_once_with(path, repository_id.architecture, None)
|
||||
sources_mock.assert_called_once_with(path, "*.diff")
|
||||
|
||||
|
||||
|
@ -49,7 +49,8 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
|
||||
application_packages_mock.assert_called_once_with([package_ahriman], None)
|
||||
application_mock.assert_called_once_with([package_ahriman], args.username, bump_pkgrel=args.increment)
|
||||
@ -70,7 +71,8 @@ def test_run_extract_packages(args: argparse.Namespace, configuration: Configura
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
extract_mock = mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
|
||||
|
||||
|
||||
@ -87,7 +89,8 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
|
||||
@ -105,7 +108,8 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, repo
|
||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
application_packages_mock.assert_called_once_with([], ["python-aur"])
|
||||
|
||||
|
||||
@ -120,7 +124,8 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
|
||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
application_packages_mock.assert_called_once_with([], None)
|
||||
|
||||
|
||||
@ -138,7 +143,8 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -155,7 +161,8 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
|
||||
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rebuild.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
|
||||
|
||||
|
||||
|
@ -31,6 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Remove.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Remove.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with([])
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
@ -34,7 +34,8 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
||||
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
RemoveUnknown.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
RemoveUnknown.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with()
|
||||
remove_mock.assert_called_once_with([package_ahriman])
|
||||
on_start_mock.assert_called_once_with()
|
||||
@ -53,7 +54,8 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
|
||||
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
RemoveUnknown.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
RemoveUnknown.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with()
|
||||
remove_mock.assert_not_called()
|
||||
print_mock.assert_called_once_with(verbose=False)
|
||||
|
@ -32,7 +32,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
extract_mock = tarfile.__enter__.return_value = MagicMock()
|
||||
mocker.patch("tarfile.TarFile.__new__", return_value=tarfile)
|
||||
|
||||
Restore.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Restore.run(args, repository_id, configuration, report=False)
|
||||
extract_mock.extractall.assert_called_once_with(path=args.output)
|
||||
|
||||
|
||||
|
@ -42,7 +42,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Search.run(args, repository_id, configuration, report=False)
|
||||
aur_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int))
|
||||
official_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int))
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
@ -62,7 +63,8 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Search.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Search.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -77,7 +79,8 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, reposi
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
||||
|
||||
Search.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Search.run(args, repository_id, configuration, report=False)
|
||||
sort_mock.assert_has_calls([
|
||||
MockCall([], "name"), MockCall().__iter__(),
|
||||
MockCall([aur_package_ahriman], "name"), MockCall().__iter__()
|
||||
@ -96,7 +99,8 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, rep
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
||||
|
||||
Search.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Search.run(args, repository_id, configuration, report=False)
|
||||
sort_mock.assert_has_calls([
|
||||
MockCall([], "field"), MockCall().__iter__(),
|
||||
MockCall([aur_package_ahriman], "field"), MockCall().__iter__()
|
||||
|
@ -35,7 +35,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
ServiceUpdates.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
||||
package_mock.assert_called_once_with(package_ahriman.base, repository.pacman, None)
|
||||
application_mock.assert_called_once_with(verbose=True, separator=" -> ")
|
||||
check_mock.assert_called_once_with(args.exit_code, True)
|
||||
@ -53,6 +54,7 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, reposi
|
||||
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
ServiceUpdates.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_not_called()
|
||||
|
@ -9,6 +9,7 @@ from unittest.mock import call as MockCall
|
||||
from ahriman.application.handlers import Setup
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
from ahriman.models.sign_settings import SignSettings
|
||||
|
||||
@ -24,14 +25,12 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.build_as_user = "ahriman"
|
||||
args.build_command = "ahriman"
|
||||
args.from_configuration = Path("/usr/share/devtools/pacman.conf.d/extra.conf")
|
||||
args.generate_salt = True
|
||||
args.makeflags_jobs = True
|
||||
args.mirror = "mirror"
|
||||
args.multilib = True
|
||||
args.packager = "John Doe <john@doe.com>"
|
||||
args.repository = "aur-clone"
|
||||
args.server = None
|
||||
args.sign_key = "key"
|
||||
args.sign_target = [SignSettings.Packages]
|
||||
@ -54,14 +53,14 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create")
|
||||
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||
|
||||
Setup.run(args, "x86_64", configuration, report=False)
|
||||
ahriman_configuration_mock.assert_called_once_with(args, "x86_64", args.repository, configuration)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.run(args, repository_id, configuration, report=False)
|
||||
ahriman_configuration_mock.assert_called_once_with(args, repository_id, configuration)
|
||||
devtools_configuration_mock.assert_called_once_with(
|
||||
args.build_command, "x86_64", args.from_configuration, args.mirror, args.multilib, args.repository,
|
||||
f"file://{repository_paths.repository}")
|
||||
repository_id, args.from_configuration, args.mirror, args.multilib, f"file://{repository_paths.repository}")
|
||||
makepkg_configuration_mock.assert_called_once_with(args.packager, args.makeflags_jobs, repository_paths)
|
||||
sudo_configuration_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
|
||||
executable_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
|
||||
sudo_configuration_mock.assert_called_once_with(repository_paths, repository_id)
|
||||
executable_mock.assert_called_once_with(repository_paths, repository_id)
|
||||
init_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -80,21 +79,20 @@ def test_run_with_server(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools")
|
||||
|
||||
Setup.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.run(args, repository_id, configuration, report=False)
|
||||
devtools_configuration_mock.assert_called_once_with(
|
||||
args.build_command, "x86_64", args.from_configuration, args.mirror, args.multilib, args.repository,
|
||||
"server")
|
||||
repository_id, args.from_configuration, args.mirror, args.multilib, "server")
|
||||
|
||||
|
||||
def test_build_command(args: argparse.Namespace) -> None:
|
||||
def test_build_command(repository_id: RepositoryId) -> None:
|
||||
"""
|
||||
must generate correct build command name
|
||||
"""
|
||||
args = _default_args(args)
|
||||
path = Path("local")
|
||||
|
||||
build_command = Setup.build_command(path, args.build_command, "x86_64")
|
||||
assert build_command.name == f"{args.build_command}-x86_64-build"
|
||||
build_command = Setup.build_command(path, repository_id)
|
||||
assert build_command.name == f"{repository_id.name}-{repository_id.architecture}-build"
|
||||
assert build_command.parent == path
|
||||
|
||||
|
||||
@ -107,19 +105,26 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
mocker.patch("pathlib.Path.open")
|
||||
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
command = Setup.build_command(repository_paths.root, args.build_command, "x86_64")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
command = Setup.build_command(repository_paths.root, repository_id)
|
||||
|
||||
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration)
|
||||
Setup.configuration_create_ahriman(args, repository_id, configuration)
|
||||
set_option_mock.assert_has_calls([
|
||||
MockCall(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
|
||||
MockCall("repository", "name", args.repository),
|
||||
MockCall(Configuration.section_name("build", "x86_64"), "makechrootpkg_flags", f"-U {args.build_as_user}"),
|
||||
MockCall(Configuration.section_name("alpm", "x86_64"), "mirror", args.mirror),
|
||||
MockCall(Configuration.section_name("sign", "x86_64"), "target",
|
||||
MockCall(Configuration.section_name("build", repository_id.name, repository_id.architecture), "build_command",
|
||||
str(command)),
|
||||
MockCall("repository", "name", repository_id.name),
|
||||
MockCall(Configuration.section_name("build", repository_id.name, repository_id.architecture),
|
||||
"makechrootpkg_flags", f"-U {args.build_as_user}"),
|
||||
MockCall(Configuration.section_name(
|
||||
"alpm", repository_id.name, repository_id.architecture), "mirror", args.mirror),
|
||||
MockCall(Configuration.section_name("sign", repository_id.name, repository_id.architecture), "target",
|
||||
" ".join([target.name.lower() for target in args.sign_target])),
|
||||
MockCall(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
||||
MockCall(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
||||
MockCall(Configuration.section_name("web", "x86_64"), "unix_socket", str(args.web_unix_socket)),
|
||||
MockCall(Configuration.section_name("sign", repository_id.name, repository_id.architecture), "key",
|
||||
args.sign_key),
|
||||
MockCall(Configuration.section_name("web", repository_id.name, repository_id.architecture), "port",
|
||||
str(args.web_port)),
|
||||
MockCall(Configuration.section_name("web", repository_id.name, repository_id.architecture), "unix_socket",
|
||||
str(args.web_unix_socket)),
|
||||
MockCall("auth", "salt", pytest.helpers.anyvar(str, strict=True)),
|
||||
])
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
@ -136,13 +141,16 @@ def test_configuration_create_ahriman_no_multilib(args: argparse.Namespace, conf
|
||||
mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
|
||||
|
||||
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.configuration_create_ahriman(args, repository_id, configuration)
|
||||
set_option_mock.assert_has_calls([
|
||||
MockCall(Configuration.section_name("alpm", "x86_64"), "mirror", args.mirror),
|
||||
MockCall(Configuration.section_name("alpm", repository_id.name, repository_id.architecture), "mirror",
|
||||
args.mirror),
|
||||
]) # non-strict check called intentionally
|
||||
|
||||
|
||||
def test_configuration_create_devtools(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_configuration_create_devtools(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create configuration for the devtools
|
||||
"""
|
||||
@ -152,13 +160,14 @@ def test_configuration_create_devtools(args: argparse.Namespace, mocker: MockerF
|
||||
add_section_mock = mocker.patch("ahriman.core.configuration.Configuration.add_section")
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
|
||||
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
|
||||
None, args.multilib, args.repository, "server")
|
||||
add_section_mock.assert_has_calls([MockCall("multilib"), MockCall(args.repository)])
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.configuration_create_devtools(repository_id, args.from_configuration, None, args.multilib, "server")
|
||||
add_section_mock.assert_has_calls([MockCall("multilib"), MockCall(repository_id.name)])
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
def test_configuration_create_devtools_mirror(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_configuration_create_devtools_mirror(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create configuration for the devtools with mirror set explicitly
|
||||
"""
|
||||
@ -176,14 +185,15 @@ def test_configuration_create_devtools_mirror(args: argparse.Namespace, mocker:
|
||||
remove_option_mock = mocker.patch("ahriman.core.configuration.Configuration.remove_option")
|
||||
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
|
||||
|
||||
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
|
||||
args.mirror, False, args.repository, "server")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.configuration_create_devtools(repository_id, args.from_configuration, args.mirror, args.multilib, "server")
|
||||
get_mock.assert_has_calls([MockCall("core", "Include", fallback=None), MockCall("extra", "Include", fallback=None)])
|
||||
remove_option_mock.assert_called_once_with("core", "Include")
|
||||
set_option_mock.assert_has_calls([MockCall("core", "Server", args.mirror)]) # non-strict check called intentionally
|
||||
|
||||
|
||||
def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create configuration for the devtools without multilib
|
||||
"""
|
||||
@ -192,8 +202,8 @@ def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, moc
|
||||
mocker.patch("ahriman.core.configuration.Configuration.set")
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
|
||||
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
|
||||
None, False, args.repository, "server")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.configuration_create_devtools(repository_id, args.from_configuration, args.mirror, False, "server")
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
@ -211,31 +221,32 @@ def test_configuration_create_makepkg(args: argparse.Namespace, repository_paths
|
||||
Path("home") / ".makepkg.conf", pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
|
||||
|
||||
def test_configuration_create_sudo(args: argparse.Namespace, repository_paths: RepositoryPaths,
|
||||
def test_configuration_create_sudo(configuration: Configuration, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create sudo configuration
|
||||
"""
|
||||
args = _default_args(args)
|
||||
chmod_text_mock = mocker.patch("pathlib.Path.chmod")
|
||||
write_text_mock = mocker.patch("pathlib.Path.write_text")
|
||||
|
||||
Setup.configuration_create_sudo(repository_paths, args.build_command, "x86_64")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.configuration_create_sudo(repository_paths, repository_id)
|
||||
chmod_text_mock.assert_called_once_with(0o400)
|
||||
write_text_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
|
||||
|
||||
def test_executable_create(args: argparse.Namespace, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
|
||||
def test_executable_create(configuration: Configuration, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create executable
|
||||
"""
|
||||
args = _default_args(args)
|
||||
chown_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.chown")
|
||||
symlink_mock = mocker.patch("pathlib.Path.symlink_to")
|
||||
unlink_mock = mocker.patch("pathlib.Path.unlink")
|
||||
|
||||
Setup.executable_create(repository_paths, args.build_command, "x86_64")
|
||||
chown_mock.assert_called_once_with(Setup.build_command(repository_paths.root, args.build_command, "x86_64"))
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Setup.executable_create(repository_paths, repository_id)
|
||||
chown_mock.assert_called_once_with(Setup.build_command(repository_paths.root, repository_id))
|
||||
symlink_mock.assert_called_once_with(Setup.ARCHBUILD_COMMAND_PATH)
|
||||
unlink_mock.assert_called_once_with(missing_ok=True)
|
||||
|
||||
|
@ -32,7 +32,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("code.interact")
|
||||
|
||||
Shell.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Shell.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
@ -46,7 +47,8 @@ def test_run_eval(args: argparse.Namespace, configuration: Configuration, reposi
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("code.InteractiveConsole.runcode")
|
||||
|
||||
Shell.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Shell.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(args.code)
|
||||
|
||||
|
||||
@ -62,7 +64,8 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, rep
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
application_mock = mocker.patch("code.interact")
|
||||
|
||||
Shell.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Shell.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
|
||||
read_mock.assert_called_once_with(encoding="utf8")
|
||||
print_mock.assert_called_once_with(verbose=False)
|
||||
|
@ -30,5 +30,6 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.sign")
|
||||
|
||||
Sign.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Sign.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with([])
|
||||
|
@ -43,7 +43,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with()
|
||||
packages_mock.assert_called_once_with(None)
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
@ -62,7 +63,8 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.core.status.client.Client.package_get", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Status.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -78,7 +80,8 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, rep
|
||||
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Status.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
print_mock.assert_has_calls([MockCall(verbose=True) for _ in range(2)])
|
||||
|
||||
|
||||
@ -93,7 +96,8 @@ def test_run_with_package_filter(args: argparse.Namespace, configuration: Config
|
||||
packages_mock = mocker.patch("ahriman.core.status.client.Client.package_get",
|
||||
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
|
||||
|
||||
Status.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
packages_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -110,7 +114,8 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, r
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Status.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
print_mock.assert_has_calls([MockCall(verbose=False) for _ in range(2)])
|
||||
|
||||
|
||||
@ -123,8 +128,9 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
|
||||
|
||||
Status.run(args, "x86_64", configuration, report=False)
|
||||
load_mock.assert_called_once_with("x86_64", configuration, database, report=True, refresh_pacman_database=0)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Status.run(args, repository_id, configuration, report=False)
|
||||
load_mock.assert_called_once_with(repository_id, configuration, database, report=True, refresh_pacman_database=0)
|
||||
|
||||
|
||||
def test_disallow_auto_architecture_run() -> None:
|
||||
|
@ -36,7 +36,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
update_self_mock = mocker.patch("ahriman.core.status.client.Client.status_update")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
StatusUpdate.run(args, repository_id, configuration, report=False)
|
||||
update_self_mock.assert_called_once_with(args.status)
|
||||
|
||||
|
||||
@ -50,7 +51,8 @@ def test_run_packages(args: argparse.Namespace, configuration: Configuration, re
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
update_mock = mocker.patch("ahriman.core.status.client.Client.package_update")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
StatusUpdate.run(args, repository_id, configuration, report=False)
|
||||
update_mock.assert_called_once_with(package_ahriman.base, args.status)
|
||||
|
||||
|
||||
@ -65,7 +67,8 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
update_mock = mocker.patch("ahriman.core.status.client.Client.package_remove")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
StatusUpdate.run(args, repository_id, configuration, report=False)
|
||||
update_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -78,8 +81,9 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False)
|
||||
load_mock.assert_called_once_with("x86_64", configuration, database, report=True, refresh_pacman_database=0)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
StatusUpdate.run(args, repository_id, configuration, report=False)
|
||||
load_mock.assert_called_once_with(repository_id, configuration, database, report=True, refresh_pacman_database=0)
|
||||
|
||||
|
||||
def test_disallow_auto_architecture_run() -> None:
|
||||
|
@ -35,7 +35,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
application_mock = mocker.patch("ahriman.core.tree.Tree.resolve", return_value=[[package_ahriman]])
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Structure.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Structure.run(args, repository_id, configuration, report=False)
|
||||
packages_mock.assert_called_once_with([package_ahriman], count=args.partitions)
|
||||
application_mock.assert_called_once_with([package_ahriman])
|
||||
print_mock.assert_has_calls([
|
||||
|
@ -33,7 +33,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.on_result")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Triggers.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(Result())
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
@ -50,6 +51,7 @@ def test_run_trigger(args: argparse.Namespace, configuration: Configuration, rep
|
||||
report_mock = mocker.patch("ahriman.core.report.ReportTrigger.on_result")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.UploadTrigger.on_result")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Triggers.run(args, repository_id, configuration, report=False)
|
||||
report_mock.assert_called_once_with(Result(), [package_ahriman])
|
||||
upload_mock.assert_not_called()
|
||||
|
@ -32,7 +32,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
return_value=["command"])
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
UnsafeCommands.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
UnsafeCommands.run(args, repository_id, configuration, report=False)
|
||||
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
print_mock.assert_called_once_with(verbose=True)
|
||||
|
||||
@ -47,7 +48,8 @@ def test_run_check(args: argparse.Namespace, configuration: Configuration, mocke
|
||||
return_value=["command"])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.check_unsafe")
|
||||
|
||||
UnsafeCommands.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
UnsafeCommands.run(args, repository_id, configuration, report=False)
|
||||
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
check_mock.assert_called_once_with(["clean"], ["command"], pytest.helpers.anyvar(int))
|
||||
|
||||
|
@ -54,7 +54,8 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
|
||||
Update.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Update.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with([package_ahriman],
|
||||
Packagers(args.username, {package_ahriman.base: "packager"}),
|
||||
bump_pkgrel=args.increment)
|
||||
@ -77,7 +78,8 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Update.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Update.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -95,7 +97,8 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
|
||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Update.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Update.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
|
||||
|
||||
|
||||
@ -111,7 +114,8 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Update.run(args, repository_id, configuration, report=False)
|
||||
updates_mock.assert_called_once_with(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs)
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_called_once_with(False, pytest.helpers.anyvar(int))
|
||||
|
@ -47,7 +47,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S
|
||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||
|
||||
Users.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
create_user_mock.assert_called_once_with(args)
|
||||
update_mock.assert_called_once_with(user)
|
||||
|
||||
@ -64,7 +65,8 @@ def test_run_empty_salt(args: argparse.Namespace, configuration: Configuration,
|
||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||
|
||||
Users.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
create_user_mock.assert_called_once_with(args)
|
||||
update_mock.assert_called_once_with(user)
|
||||
|
||||
@ -83,7 +85,8 @@ def test_run_empty_salt_without_password(args: argparse.Namespace, configuration
|
||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||
|
||||
Users.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
create_user_mock.assert_called_once_with(args)
|
||||
update_mock.assert_called_once_with(user)
|
||||
|
||||
@ -99,7 +102,8 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
list_mock.assert_called_once_with("user", args.role)
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
|
||||
@ -116,7 +120,8 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -130,7 +135,8 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, data
|
||||
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, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Users.run(args, repository_id, configuration, report=False)
|
||||
remove_mock.assert_called_once_with(args.username)
|
||||
|
||||
|
||||
|
@ -33,8 +33,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
application_mock = mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=False)
|
||||
|
||||
Validate.run(args, "x86_64", configuration, report=False)
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Validate.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(configuration.dump())
|
||||
print_mock.assert_called_once_with(verbose=True)
|
||||
|
||||
@ -47,7 +47,8 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, mocker
|
||||
mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=True)
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Validate.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Validate.run(args, repository_id, configuration, report=False)
|
||||
print_mock.assert_not_called()
|
||||
|
||||
|
||||
@ -55,7 +56,8 @@ def test_schema(configuration: Configuration) -> None:
|
||||
"""
|
||||
must generate full schema correctly
|
||||
"""
|
||||
schema = Validate.schema("x86_64", configuration)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
schema = Validate.schema(repository_id, configuration)
|
||||
|
||||
# defaults
|
||||
assert schema.pop("console")
|
||||
@ -86,7 +88,9 @@ def test_schema_invalid_trigger(configuration: Configuration) -> None:
|
||||
"""
|
||||
configuration.set_option("build", "triggers", "some.invalid.trigger.path.Trigger")
|
||||
configuration.remove_option("build", "triggers_known")
|
||||
assert Validate.schema("x86_64", configuration) == CONFIGURATION_SCHEMA
|
||||
_, repository_id = configuration.check_loaded()
|
||||
|
||||
assert Validate.schema(repository_id, configuration) == CONFIGURATION_SCHEMA
|
||||
|
||||
|
||||
def test_schema_erase_required() -> None:
|
||||
|
@ -14,7 +14,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Versions.package_dependencies")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Versions.run(args, "x86_64", configuration, report=False)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Versions.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with("ahriman")
|
||||
print_mock.assert_has_calls([MockCall(verbose=False, separator=" "), MockCall(verbose=False, separator=" ")])
|
||||
|
||||
|
@ -41,8 +41,9 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
stop_mock = mocker.patch("ahriman.core.spawn.Spawn.stop")
|
||||
join_mock = mocker.patch("ahriman.core.spawn.Spawn.join")
|
||||
|
||||
Web.run(args, "x86_64", configuration, report=False)
|
||||
setup_mock.assert_called_once_with("x86_64", configuration, pytest.helpers.anyvar(int))
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Web.run(args, repository_id, configuration, report=False)
|
||||
setup_mock.assert_called_once_with(repository_id, configuration, pytest.helpers.anyvar(int))
|
||||
run_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
start_mock.assert_called_once_with()
|
||||
stop_mock.assert_called_once_with()
|
||||
@ -53,33 +54,35 @@ def test_extract_arguments(args: argparse.Namespace, configuration: Configuratio
|
||||
"""
|
||||
must extract correct args
|
||||
"""
|
||||
_, repository_id = configuration.check_loaded()
|
||||
expected = [
|
||||
"--architecture", "x86_64",
|
||||
"--architecture", repository_id.architecture,
|
||||
"--repository", repository_id.name,
|
||||
"--configuration", str(configuration.path),
|
||||
]
|
||||
|
||||
probe = _default_args(args)
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
probe.force = True
|
||||
expected.extend(["--force"])
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
probe.log_handler = LogHandler.Console
|
||||
expected.extend(["--log-handler", probe.log_handler.value])
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
probe.quiet = True
|
||||
expected.extend(["--quiet"])
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
probe.unsafe = True
|
||||
expected.extend(["--unsafe"])
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
configuration.set_option("web", "wait_timeout", "60")
|
||||
expected.extend(["--wait-timeout", "60"])
|
||||
assert list(Web.extract_arguments(probe, "x86_64", configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
|
||||
|
||||
def test_extract_arguments_full(parser: argparse.ArgumentParser, configuration: Configuration):
|
||||
@ -101,8 +104,10 @@ def test_extract_arguments_full(parser: argparse.ArgumentParser, configuration:
|
||||
value = action.type(value)
|
||||
setattr(args, action.dest, value)
|
||||
|
||||
assert list(Web.extract_arguments(args, "x86_64", configuration)) == [
|
||||
"--architecture", "x86_64",
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert list(Web.extract_arguments(args, repository_id, configuration)) == [
|
||||
"--architecture", repository_id.architecture,
|
||||
"--repository", repository_id.name,
|
||||
"--configuration", str(configuration.path),
|
||||
"--force",
|
||||
"--log-handler", "console",
|
||||
|
@ -5,6 +5,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application import ahriman
|
||||
from ahriman.application.handlers import Handler
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.log_handler import LogHandler
|
||||
@ -65,6 +66,14 @@ def test_multiple_architectures(parser: argparse.ArgumentParser) -> None:
|
||||
assert args.architecture == ["x86_64", "i686"]
|
||||
|
||||
|
||||
def test_multiple_repositories(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
must accept multiple architectures
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo1", "-r", "repo2", "service-config"])
|
||||
assert args.repository == ["repo1", "repo2"]
|
||||
|
||||
|
||||
def test_subparsers_aur_search(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
aur-search command must imply architecture list, lock, report, quiet and unsafe
|
||||
@ -707,8 +716,7 @@ def test_subparsers_service_setup(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-setup command must imply lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone"])
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
@ -720,11 +728,10 @@ def test_subparsers_service_setup_option_from_configuration(parser: argparse.Arg
|
||||
"""
|
||||
service-setup command must convert from-configuration option to path instance
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone"])
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>"])
|
||||
assert isinstance(args.from_configuration, Path)
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone", "--from-configuration", "path"])
|
||||
"--from-configuration", "path"])
|
||||
assert isinstance(args.from_configuration, Path)
|
||||
|
||||
|
||||
@ -733,7 +740,7 @@ def test_subparsers_service_setup_option_sign_target(parser: argparse.ArgumentPa
|
||||
service-setup command must convert sign-target option to SignSettings instance
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "service-setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone", "--sign-target", "packages"])
|
||||
"--sign-target", "packages"])
|
||||
assert args.sign_target
|
||||
assert all(isinstance(target, SignSettings) for target in args.sign_target)
|
||||
|
||||
@ -836,13 +843,17 @@ def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
application must be run
|
||||
"""
|
||||
args.architecture = "x86_64"
|
||||
path, repository_id = configuration.check_loaded()
|
||||
|
||||
args.architecture = repository_id.architecture
|
||||
args.repository = repository_id.name
|
||||
args.configuration = path
|
||||
args.handler = Handler
|
||||
|
||||
mocker.patch("argparse.ArgumentParser.parse_args", return_value=args)
|
||||
|
||||
assert ahriman.run() == 1
|
||||
assert ahriman.run() == 1 # not implemented
|
||||
|
@ -16,7 +16,6 @@ from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.core.spawn import Spawn
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
from ahriman.models.user import User
|
||||
from ahriman.web.web import setup_service
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user