mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-03-21 17:13:39 +00:00
feat: allow to use single web instance for all repositories (#114)
* Allow to use single web instance for any repository * some improvements * drop includes from user home directory, introduce new variables to docker The old solution didn't actually work as expected, because devtools configuration belongs to filesystem (as well as sudo one), so it was still required to run setup command. In order to handle additional repositories, the POSTSETUP and PRESETUP commands variables have been introduced. FAQ has been updated as well * raise 404 in case if repository is unknown
This commit is contained in:
@@ -99,8 +99,8 @@ def test_with_dependencies(application: Application, package_ahriman: Package, p
|
||||
result = application.with_dependencies([package_ahriman], process_dependencies=True)
|
||||
assert {package.base: package for package in result} == packages
|
||||
package_aur_mock.assert_has_calls([
|
||||
MockCall(package_python_schedule.base, application.repository.pacman, package_ahriman.packager),
|
||||
MockCall("python-installer", application.repository.pacman, package_ahriman.packager),
|
||||
MockCall(package_python_schedule.base, package_ahriman.packager),
|
||||
MockCall("python-installer", package_ahriman.packager),
|
||||
], any_order=True)
|
||||
package_local_mock.assert_has_calls([
|
||||
MockCall(application.repository.paths.cache_for("python"), "x86_64", package_ahriman.packager),
|
||||
|
||||
@@ -30,7 +30,12 @@ def test_call(args: argparse.Namespace, configuration: Configuration, mocker: Mo
|
||||
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)
|
||||
log_load_mock.assert_called_once_with(
|
||||
repository_id,
|
||||
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)
|
||||
|
||||
@@ -115,13 +120,24 @@ def test_run(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
Handler.run(args, repository_id, configuration, report=True)
|
||||
|
||||
|
||||
def test_check_if_empty() -> None:
|
||||
"""
|
||||
must raise exception in case if predicate is True and enabled
|
||||
"""
|
||||
Handler.check_if_empty(False, False)
|
||||
Handler.check_if_empty(True, False)
|
||||
Handler.check_if_empty(False, True)
|
||||
with pytest.raises(ExitCode):
|
||||
Handler.check_if_empty(True, True)
|
||||
|
||||
|
||||
def test_repositories_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate list of available repositories based on flags
|
||||
"""
|
||||
args.architecture = ["arch"]
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
args.repository = ["repo"]
|
||||
args.repository = "repo"
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
|
||||
@@ -135,7 +151,7 @@ def test_repositories_extract_repository(args: argparse.Namespace, configuration
|
||||
"""
|
||||
must generate list of available repositories based on flags and tree
|
||||
"""
|
||||
args.architecture = ["arch"]
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories",
|
||||
@@ -151,7 +167,7 @@ def test_repositories_extract_repository_legacy(args: argparse.Namespace, config
|
||||
"""
|
||||
must generate list of available repositories based on flags and tree
|
||||
"""
|
||||
args.architecture = ["arch"]
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories",
|
||||
@@ -168,7 +184,7 @@ def test_repositories_extract_architecture(args: argparse.Namespace, configurati
|
||||
must read repository name from config
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository = ["repo"]
|
||||
args.repository = "repo"
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures",
|
||||
return_value={"arch"})
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
@@ -207,6 +223,21 @@ def test_repositories_extract_systemd(args: argparse.Namespace, configuration: C
|
||||
known_repositories_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_repositories_extract_systemd_with_dash(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must extract repository list by using dash separated identifier
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository_id = "i686-some-repo-name"
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
|
||||
assert Handler.repositories_extract(args) == [RepositoryId("i686", "some-repo-name")]
|
||||
known_architectures_mock.assert_not_called()
|
||||
known_repositories_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_repositories_extract_systemd_legacy(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
@@ -221,14 +252,3 @@ def test_repositories_extract_systemd_legacy(args: argparse.Namespace, configura
|
||||
assert Handler.repositories_extract(args) == [RepositoryId("i686", "aur-clone")]
|
||||
known_architectures_mock.assert_not_called()
|
||||
known_repositories_mock.assert_called_once_with(configuration.repository_paths.root)
|
||||
|
||||
|
||||
def test_check_if_empty() -> None:
|
||||
"""
|
||||
must raise exception in case if predicate is True and enabled
|
||||
"""
|
||||
Handler.check_if_empty(False, False)
|
||||
Handler.check_if_empty(True, False)
|
||||
Handler.check_if_empty(False, True)
|
||||
with pytest.raises(ExitCode):
|
||||
Handler.check_if_empty(True, True)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
@@ -16,6 +17,9 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.info = False
|
||||
args.key = None
|
||||
args.section = None
|
||||
args.secure = True
|
||||
return args
|
||||
|
||||
@@ -35,6 +39,48 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
print_mock.assert_called()
|
||||
|
||||
|
||||
def test_run_info(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command with info
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.info = True
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Dump.run(args, repository_id, configuration, report=False)
|
||||
print_mock.assert_called()
|
||||
|
||||
|
||||
def test_run_section(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command with filter by section
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.section = "settings"
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Dump.run(args, repository_id, configuration, report=False)
|
||||
print_mock.assert_called_once_with(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=" = ")
|
||||
|
||||
|
||||
def test_run_section_key(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command with filter by section and key
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.section = "settings"
|
||||
args.key = "include"
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Dump.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_not_called()
|
||||
print_mock.assert_called_once_with(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": ")
|
||||
|
||||
|
||||
def test_disallow_multi_architecture_run() -> None:
|
||||
"""
|
||||
must not allow multi architecture run
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Repositories
|
||||
from ahriman.core.configuration import Configuration
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.configuration = None # doesn't matter actually
|
||||
args.id_only = False
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Handler.repositories_extract",
|
||||
return_value=[repository_id])
|
||||
|
||||
Repositories.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
print_mock.assert_called_once_with(verbose=not args.id_only, log_fn=pytest.helpers.anyvar(int), separator=": ")
|
||||
@@ -44,8 +44,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
|
||||
_, 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))
|
||||
aur_search_mock.assert_called_once_with("ahriman")
|
||||
official_search_mock.assert_called_once_with("ahriman")
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
print_mock.assert_has_calls([
|
||||
MockCall(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": "),
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
|
||||
_, 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)
|
||||
package_mock.assert_called_once_with(package_ahriman.base, None)
|
||||
application_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" -> ")
|
||||
check_mock.assert_called_once_with(args.exit_code, True)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.architecture = ["x86_64"]
|
||||
args.architecture = "x86_64"
|
||||
args.build_as_user = "ahriman"
|
||||
args.from_configuration = Path("/usr/share/devtools/pacman.conf.d/extra.conf")
|
||||
args.generate_salt = True
|
||||
@@ -33,7 +33,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.mirror = "mirror"
|
||||
args.multilib = True
|
||||
args.packager = "John Doe <john@doe.com>"
|
||||
args.repository = ["aur-clone"]
|
||||
args.repository = "aur-clone"
|
||||
args.server = None
|
||||
args.sign_key = "key"
|
||||
args.sign_target = [SignSettings.Packages]
|
||||
@@ -127,6 +127,7 @@ 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")
|
||||
remove_mock = mocker.patch("pathlib.Path.unlink", autospec=True)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
command = Setup.build_command(repository_paths.root, repository_id)
|
||||
|
||||
@@ -143,13 +144,12 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
" ".join([target.name.lower() for target in args.sign_target])),
|
||||
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("web", "port", str(args.web_port)),
|
||||
MockCall("web", "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))
|
||||
remove_mock.assert_called_once_with(configuration.include / "00-setup-overrides.ini", missing_ok=True)
|
||||
|
||||
|
||||
def test_configuration_create_ahriman_no_multilib(args: argparse.Namespace, configuration: Configuration,
|
||||
|
||||
@@ -47,13 +47,16 @@ def test_run_packages(args: argparse.Namespace, configuration: Configuration, re
|
||||
must run command with specified packages
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.package = [package_ahriman.base]
|
||||
args.package = [package_ahriman.base, "package"]
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
|
||||
add_mock = mocker.patch("ahriman.core.status.client.Client.package_add")
|
||||
update_mock = mocker.patch("ahriman.core.status.client.Client.package_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
StatusUpdate.run(args, repository_id, configuration, report=False)
|
||||
update_mock.assert_called_once_with(package_ahriman.base, args.status)
|
||||
add_mock.assert_called_once_with(package_ahriman, args.status)
|
||||
update_mock.assert_called_once_with("package", args.status)
|
||||
|
||||
|
||||
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
|
||||
@@ -20,6 +20,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.parser = lambda: True
|
||||
args.configuration = None # doesn't matter actually
|
||||
args.force = False
|
||||
args.log_handler = None
|
||||
args.report = True
|
||||
@@ -35,15 +36,16 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
setup_mock = mocker.patch("ahriman.web.web.setup_service")
|
||||
setup_mock = mocker.patch("ahriman.web.web.setup_server")
|
||||
run_mock = mocker.patch("ahriman.web.web.run_server")
|
||||
start_mock = mocker.patch("ahriman.core.spawn.Spawn.start")
|
||||
stop_mock = mocker.patch("ahriman.core.spawn.Spawn.stop")
|
||||
join_mock = mocker.patch("ahriman.core.spawn.Spawn.join")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[repository_id])
|
||||
|
||||
Web.run(args, repository_id, configuration, report=False)
|
||||
setup_mock.assert_called_once_with(repository_id, configuration, pytest.helpers.anyvar(int))
|
||||
setup_mock.assert_called_once_with(configuration, pytest.helpers.anyvar(int), [repository_id])
|
||||
run_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
start_mock.assert_called_once_with()
|
||||
stop_mock.assert_called_once_with()
|
||||
@@ -54,35 +56,32 @@ def test_extract_arguments(args: argparse.Namespace, configuration: Configuratio
|
||||
"""
|
||||
must extract correct args
|
||||
"""
|
||||
_, repository_id = configuration.check_loaded()
|
||||
expected = [
|
||||
"--architecture", repository_id.architecture,
|
||||
"--repository", repository_id.name,
|
||||
"--configuration", str(configuration.path),
|
||||
]
|
||||
|
||||
probe = _default_args(args)
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
probe.force = True
|
||||
expected.extend(["--force"])
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
probe.log_handler = LogHandler.Console
|
||||
expected.extend(["--log-handler", probe.log_handler.value])
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
probe.quiet = True
|
||||
expected.extend(["--quiet"])
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
probe.unsafe = True
|
||||
expected.extend(["--unsafe"])
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
configuration.set_option("web", "wait_timeout", "60")
|
||||
expected.extend(["--wait-timeout", "60"])
|
||||
assert list(Web.extract_arguments(probe, repository_id, configuration)) == expected
|
||||
assert list(Web.extract_arguments(probe, configuration)) == expected
|
||||
|
||||
|
||||
def test_extract_arguments_full(parser: argparse.ArgumentParser, configuration: Configuration):
|
||||
@@ -104,10 +103,7 @@ def test_extract_arguments_full(parser: argparse.ArgumentParser, configuration:
|
||||
value = action.type(value)
|
||||
setattr(args, action.dest, value)
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
assert list(Web.extract_arguments(args, repository_id, configuration)) == [
|
||||
"--architecture", repository_id.architecture,
|
||||
"--repository", repository_id.name,
|
||||
assert list(Web.extract_arguments(args, configuration)) == [
|
||||
"--configuration", str(configuration.path),
|
||||
"--force",
|
||||
"--log-handler", "console",
|
||||
|
||||
@@ -67,14 +67,6 @@ def test_parser_option_architecture_empty(parser: argparse.ArgumentParser) -> No
|
||||
assert args.architecture is None
|
||||
|
||||
|
||||
def test_parser_option_architecture_multiple(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
must accept multiple architectures
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-a", "i686", "service-config"])
|
||||
assert args.architecture == ["x86_64", "i686"]
|
||||
|
||||
|
||||
def test_parser_option_repository_empty(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
must parse empty repository list as None
|
||||
@@ -83,24 +75,16 @@ def test_parser_option_repository_empty(parser: argparse.ArgumentParser) -> None
|
||||
assert args.repository is None
|
||||
|
||||
|
||||
def test_parser_option_repository_multiple(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, quiet, report, repository and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["aur-search", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -109,7 +93,7 @@ def test_subparsers_aur_search_option_architecture(parser: argparse.ArgumentPars
|
||||
aur-search command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "aur-search", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_aur_search_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -117,7 +101,7 @@ def test_subparsers_aur_search_option_repository(parser: argparse.ArgumentParser
|
||||
aur-search command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "aur-search", "ahriman"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_help(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -125,11 +109,11 @@ def test_subparsers_help(parser: argparse.ArgumentParser) -> None:
|
||||
help command must imply architecture list, lock, quiet, report, repository, unsafe and parser
|
||||
"""
|
||||
args = parser.parse_args(["help"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
@@ -139,7 +123,7 @@ def test_subparsers_help_option_architecture(parser: argparse.ArgumentParser) ->
|
||||
help command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_help_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -147,7 +131,7 @@ def test_subparsers_help_option_repository(parser: argparse.ArgumentParser) -> N
|
||||
help command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "help"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_help_commands_unsafe(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -155,11 +139,11 @@ def test_subparsers_help_commands_unsafe(parser: argparse.ArgumentParser) -> Non
|
||||
help-commands-unsafe command must imply architecture list, lock, quiet, report, repository, unsafe and parser
|
||||
"""
|
||||
args = parser.parse_args(["help-commands-unsafe"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
@@ -169,7 +153,7 @@ def test_subparsers_help_commands_unsafe_option_architecture(parser: argparse.Ar
|
||||
help-commands-unsafe command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help-commands-unsafe"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_help_commands_unsafe_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -177,7 +161,7 @@ def test_subparsers_help_commands_unsafe_option_repository(parser: argparse.Argu
|
||||
help-commands-unsafe command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "help-commands-unsafe"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_help_updates(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -185,11 +169,11 @@ def test_subparsers_help_updates(parser: argparse.ArgumentParser) -> None:
|
||||
help-updates command must imply architecture list, lock, quiet, report, repository, and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["help-updates"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -198,7 +182,7 @@ def test_subparsers_help_updates_option_architecture(parser: argparse.ArgumentPa
|
||||
help-updates command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help-updates"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_help_updates_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -206,7 +190,7 @@ def test_subparsers_help_updates_option_repository(parser: argparse.ArgumentPars
|
||||
help-updates command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "help-updates"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_help_version(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -214,11 +198,11 @@ def test_subparsers_help_version(parser: argparse.ArgumentParser) -> None:
|
||||
help-version command must imply architecture, lock, quiet, report, repository and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["help-version"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -227,7 +211,7 @@ def test_subparsers_help_version_option_architecture(parser: argparse.ArgumentPa
|
||||
help-version command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help-version"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_help_version_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -235,7 +219,7 @@ def test_subparsers_help_version_option_repository(parser: argparse.ArgumentPars
|
||||
help-version command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "help-version"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_package_add_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -245,7 +229,7 @@ def test_subparsers_package_add_option_architecture(parser: argparse.ArgumentPar
|
||||
args = parser.parse_args(["package-add", "ahriman"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "package-add", "ahriman"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_package_add_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -255,7 +239,7 @@ def test_subparsers_package_add_option_repository(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["package-add", "ahriman"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "package-add", "ahriman"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_package_add_option_refresh(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -277,7 +261,7 @@ def test_subparsers_package_remove_option_architecture(parser: argparse.Argument
|
||||
args = parser.parse_args(["package-remove", "ahriman"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "package-remove", "ahriman"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_package_remove_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -287,7 +271,7 @@ def test_subparsers_package_remove_option_repository(parser: argparse.ArgumentPa
|
||||
args = parser.parse_args(["package-remove", "ahriman"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "package-remove", "ahriman"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_package_status(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -295,11 +279,11 @@ def test_subparsers_package_status(parser: argparse.ArgumentParser) -> None:
|
||||
package-status command must imply lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "package-status"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -308,12 +292,12 @@ def test_subparsers_package_status_remove(parser: argparse.ArgumentParser) -> No
|
||||
package-status-remove command must imply action, lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "package-status-remove", "ahriman"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.action == Action.Remove
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -322,12 +306,12 @@ def test_subparsers_package_status_update(parser: argparse.ArgumentParser) -> No
|
||||
package-status-update command must imply action, lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "package-status-update"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.action == Action.Update
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -347,10 +331,10 @@ def test_subparsers_patch_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["patch-add", "ahriman", "version"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_add_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -358,7 +342,7 @@ def test_subparsers_patch_add_option_architecture(parser: argparse.ArgumentParse
|
||||
patch-add command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "patch-add", "ahriman", "version"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_add_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -366,7 +350,7 @@ def test_subparsers_patch_add_option_repository(parser: argparse.ArgumentParser)
|
||||
patch-add command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "patch-add", "ahriman", "version"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_list(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -375,10 +359,10 @@ def test_subparsers_patch_list(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["patch-list", "ahriman"])
|
||||
assert args.action == Action.List
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -387,7 +371,7 @@ def test_subparsers_patch_list_option_architecture(parser: argparse.ArgumentPars
|
||||
patch-list command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "patch-list", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_list_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -395,7 +379,7 @@ def test_subparsers_patch_list_option_repository(parser: argparse.ArgumentParser
|
||||
patch-list command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "patch-list", "ahriman"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_list_option_variable_empty(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -420,10 +404,10 @@ def test_subparsers_patch_remove(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["patch-remove", "ahriman"])
|
||||
assert args.action == Action.Remove
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_remove_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -431,7 +415,7 @@ def test_subparsers_patch_remove_option_architecture(parser: argparse.ArgumentPa
|
||||
patch-remove command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "patch-remove", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_remove_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -439,7 +423,7 @@ def test_subparsers_patch_remove_option_repository(parser: argparse.ArgumentPars
|
||||
patch-remove command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "patch-remove", "ahriman"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_remove_option_variable_empty(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -464,10 +448,10 @@ def test_subparsers_patch_set_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["patch-set-add", "ahriman"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.variable is None
|
||||
|
||||
|
||||
@@ -476,7 +460,7 @@ def test_subparsers_patch_set_add_option_architecture(parser: argparse.ArgumentP
|
||||
patch-set-add command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "patch-set-add", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_set_add_option_package(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -492,7 +476,7 @@ def test_subparsers_patch_set_add_option_repository(parser: argparse.ArgumentPar
|
||||
patch-set-add command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "patch-set-add", "ahriman"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_patch_set_add_option_track(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -508,10 +492,10 @@ def test_subparsers_repo_backup(parser: argparse.ArgumentParser) -> None:
|
||||
repo-backup command must imply architecture list, lock, report, repository and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["repo-backup", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -520,7 +504,7 @@ def test_subparsers_repo_backup_option_architecture(parser: argparse.ArgumentPar
|
||||
repo-backup command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-backup", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_repo_backup_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -528,7 +512,7 @@ def test_subparsers_repo_backup_option_repository(parser: argparse.ArgumentParse
|
||||
repo-backup command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "repo-backup", "output.zip"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_repo_check(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -550,7 +534,7 @@ def test_subparsers_repo_check_option_architecture(parser: argparse.ArgumentPars
|
||||
args = parser.parse_args(["repo-check"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-check"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_check_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -560,7 +544,7 @@ def test_subparsers_repo_check_option_repository(parser: argparse.ArgumentParser
|
||||
args = parser.parse_args(["repo-check"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-check"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_check_option_refresh(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -590,7 +574,7 @@ def test_subparsers_repo_create_keyring_option_architecture(parser: argparse.Arg
|
||||
args = parser.parse_args(["repo-create-keyring"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-create-keyring"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_create_keyring_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -600,7 +584,7 @@ def test_subparsers_repo_create_keyring_option_repository(parser: argparse.Argum
|
||||
args = parser.parse_args(["repo-create-keyring"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-create-keyring"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_create_mirrorlist(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -618,7 +602,7 @@ def test_subparsers_repo_create_mirrorlist_option_architecture(parser: argparse.
|
||||
args = parser.parse_args(["repo-create-mirrorlist"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-create-mirrorlist"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_create_mirrorlist_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -628,7 +612,7 @@ def test_subparsers_repo_create_mirrorlist_option_repository(parser: argparse.Ar
|
||||
args = parser.parse_args(["repo-create-mirrorlist"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-create-mirrorlist"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_daemon(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -670,7 +654,7 @@ def test_subparsers_repo_rebuild_option_architecture(parser: argparse.ArgumentPa
|
||||
args = parser.parse_args(["repo-rebuild"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-rebuild"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_rebuild_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -680,7 +664,7 @@ def test_subparsers_repo_rebuild_option_repository(parser: argparse.ArgumentPars
|
||||
args = parser.parse_args(["repo-rebuild"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-rebuild"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_rebuild_option_depends_on_empty(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -714,7 +698,7 @@ def test_subparsers_repo_remove_unknown_option_architecture(parser: argparse.Arg
|
||||
args = parser.parse_args(["repo-remove-unknown"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-remove-unknown"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_remove_unknown_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -724,7 +708,7 @@ def test_subparsers_repo_remove_unknown_option_repository(parser: argparse.Argum
|
||||
args = parser.parse_args(["repo-remove-unknown"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-remove-unknown"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_report(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -742,7 +726,7 @@ def test_subparsers_repo_report_option_architecture(parser: argparse.ArgumentPar
|
||||
args = parser.parse_args(["repo-report"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-report"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_report_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -752,7 +736,7 @@ def test_subparsers_repo_report_option_repository(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["repo-report"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-report"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_restore(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -760,10 +744,10 @@ def test_subparsers_repo_restore(parser: argparse.ArgumentParser) -> None:
|
||||
repo-restore command must imply architecture list, lock, report, repository and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["repo-restore", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -772,7 +756,7 @@ def test_subparsers_repo_restore_option_architecture(parser: argparse.ArgumentPa
|
||||
repo-restore command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-restore", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_repo_restore_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -780,7 +764,7 @@ def test_subparsers_repo_restore_option_repository(parser: argparse.ArgumentPars
|
||||
repo-restore command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "repo-restore", "output.zip"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_repo_sign_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -790,7 +774,7 @@ def test_subparsers_repo_sign_option_architecture(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["repo-sign"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-sign"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_sign_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -800,7 +784,7 @@ def test_subparsers_repo_sign_option_repository(parser: argparse.ArgumentParser)
|
||||
args = parser.parse_args(["repo-sign"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-sign"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_status_update(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -808,12 +792,12 @@ def test_subparsers_repo_status_update(parser: argparse.ArgumentParser) -> None:
|
||||
re[p-status-update command must imply action, lock, quiet, report, package and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "package-status-update"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.action == Action.Update
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert not args.package
|
||||
assert args.unsafe
|
||||
|
||||
@@ -843,7 +827,7 @@ def test_subparsers_repo_sync_option_architecture(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["repo-sync"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-sync"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_sync_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -853,7 +837,7 @@ def test_subparsers_repo_sync_option_repository(parser: argparse.ArgumentParser)
|
||||
args = parser.parse_args(["repo-sync"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-sync"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_tree(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -874,7 +858,7 @@ def test_subparsers_repo_tree_option_architecture(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["repo-tree"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-tree"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_tree_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -884,7 +868,7 @@ def test_subparsers_repo_tree_option_repository(parser: argparse.ArgumentParser)
|
||||
args = parser.parse_args(["repo-tree"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-tree"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_tree_option_partitions(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -904,7 +888,7 @@ def test_subparsers_repo_triggers_option_architecture(parser: argparse.ArgumentP
|
||||
args = parser.parse_args(["repo-triggers"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-triggers"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_triggers_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -914,7 +898,7 @@ def test_subparsers_repo_triggers_option_repository(parser: argparse.ArgumentPar
|
||||
args = parser.parse_args(["repo-triggers"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-triggers"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_update_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -924,7 +908,7 @@ def test_subparsers_repo_update_option_architecture(parser: argparse.ArgumentPar
|
||||
args = parser.parse_args(["repo-update"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-update"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_repo_update_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -934,7 +918,7 @@ def test_subparsers_repo_update_option_repository(parser: argparse.ArgumentParse
|
||||
args = parser.parse_args(["repo-update"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "repo-update"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_repo_update_option_refresh(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -965,7 +949,7 @@ def test_subparsers_service_clean_option_architecture(parser: argparse.ArgumentP
|
||||
args = parser.parse_args(["service-clean"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "service-clean"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
|
||||
|
||||
def test_subparsers_service_clean_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -975,7 +959,7 @@ def test_subparsers_service_clean_option_repository(parser: argparse.ArgumentPar
|
||||
args = parser.parse_args(["service-clean"])
|
||||
assert args.repository is None
|
||||
args = parser.parse_args(["-r", "repo", "service-clean"])
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
|
||||
|
||||
def test_subparsers_service_config(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -983,24 +967,41 @@ def test_subparsers_service_config(parser: argparse.ArgumentParser) -> None:
|
||||
service-config command must imply lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-config"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
def test_subparsers_service_config_option_section_key(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-config command must parse optional section and key arguments
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-config"])
|
||||
assert args.section is None
|
||||
assert args.key is None
|
||||
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-config", "section"])
|
||||
assert args.section == "section"
|
||||
assert args.key is None
|
||||
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-config", "section", "key"])
|
||||
assert args.section == "section"
|
||||
assert args.key == "key"
|
||||
|
||||
|
||||
def test_subparsers_service_config_validate(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-config-validate command must imply lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-config-validate"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -1009,10 +1010,10 @@ def test_subparsers_service_key_import(parser: argparse.ArgumentParser) -> None:
|
||||
service-key-import command must imply architecture list, lock, report and repository
|
||||
"""
|
||||
args = parser.parse_args(["service-key-import", "key"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_service_key_import_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1020,7 +1021,7 @@ def test_subparsers_service_key_import_option_architecture(parser: argparse.Argu
|
||||
service-key-import command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "service-key-import", "key"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_service_key_import_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1028,7 +1029,35 @@ def test_subparsers_service_key_import_option_repository(parser: argparse.Argume
|
||||
service-key-import command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "service-key-import", "key"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_service_repositories(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-repositories command must imply architecture, lock, report, repository and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["service-repositories"])
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
def test_subparsers_service_repositories_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-repositories command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "service-repositories"])
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_service_repositories_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
service-repositories command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "service-repositories"])
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_service_setup(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1036,11 +1065,11 @@ def test_subparsers_service_setup(parser: argparse.ArgumentParser) -> None:
|
||||
service-setup command must imply lock, quiet, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "service-setup", "--packager", "John Doe <john@doe.com>"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.architecture == "x86_64"
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == "repo"
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -1107,11 +1136,11 @@ def test_subparsers_user_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["user-add", "username"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_user_add_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1119,7 +1148,7 @@ def test_subparsers_user_add_option_architecture(parser: argparse.ArgumentParser
|
||||
user-add command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "user-add", "username"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_user_add_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1127,7 +1156,7 @@ def test_subparsers_user_add_option_repository(parser: argparse.ArgumentParser)
|
||||
user-add command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "user-add", "username"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_user_add_option_role(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1146,11 +1175,11 @@ def test_subparsers_user_list(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["user-list"])
|
||||
assert args.action == Action.List
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@@ -1159,7 +1188,7 @@ def test_subparsers_user_list_option_architecture(parser: argparse.ArgumentParse
|
||||
user-list command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "user-list"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_user_list_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1167,7 +1196,7 @@ def test_subparsers_user_list_option_repository(parser: argparse.ArgumentParser)
|
||||
user-list command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "user-list"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_user_list_option_role(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1184,11 +1213,11 @@ def test_subparsers_user_remove(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
args = parser.parse_args(["user-remove", "username"])
|
||||
assert args.action == Action.Remove
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
assert args.lock is None
|
||||
assert args.quiet
|
||||
assert not args.report
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_user_remove_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1196,7 +1225,7 @@ def test_subparsers_user_remove_option_architecture(parser: argparse.ArgumentPar
|
||||
user-remove command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "user-remove", "username"])
|
||||
assert args.architecture == [""]
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_user_remove_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
@@ -1204,20 +1233,36 @@ def test_subparsers_user_remove_option_repository(parser: argparse.ArgumentParse
|
||||
user-remove command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "user-remove", "username"])
|
||||
assert args.repository == [""]
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
web command must imply report and parser
|
||||
web command must imply architecture, report, repository and parser
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "-r", "repo", "web"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
args = parser.parse_args(["web"])
|
||||
assert args.architecture == ""
|
||||
assert not args.report
|
||||
assert args.repository == ["repo"]
|
||||
assert args.repository == ""
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
|
||||
def test_subparsers_web_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
web command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "web"])
|
||||
assert args.architecture == ""
|
||||
|
||||
|
||||
def test_subparsers_web_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
web command must correctly parse repository list
|
||||
"""
|
||||
args = parser.parse_args(["-r", "repo", "web"])
|
||||
assert args.repository == ""
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
application must be run
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_path(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
assert Lock(args, repository_id, configuration).path is None
|
||||
|
||||
args.lock = Path("/run/ahriman.lock")
|
||||
assert Lock(args, repository_id, configuration).path == Path("/run/ahriman_aur-clone_x86_64.lock")
|
||||
assert Lock(args, repository_id, configuration).path == Path("/run/ahriman_x86_64-aur-clone.lock")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
args.lock = Path("/")
|
||||
|
||||
Reference in New Issue
Block a user