mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
more options in setup command
This commit is contained in:
@ -15,6 +15,9 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.no_multilib = False
|
||||
args.packager = "John Doe <john@doe.com>"
|
||||
args.repository = "aur-clone"
|
||||
args.sign_key = "key"
|
||||
args.sign_target = ["packages"]
|
||||
args.web_port = 8080
|
||||
return args
|
||||
|
||||
|
||||
@ -58,14 +61,19 @@ def test_create_ahriman_configuration(args: argparse.Namespace, configuration: C
|
||||
write_mock = mocker.patch("configparser.RawConfigParser.write")
|
||||
|
||||
command = Setup.build_command(args.build_command, "x86_64")
|
||||
Setup.create_ahriman_configuration(args.build_command, "x86_64", args.repository, configuration.include)
|
||||
Setup.create_ahriman_configuration(args, "x86_64", args.repository, configuration.include)
|
||||
add_section_mock.assert_has_calls([
|
||||
mock.call("build"),
|
||||
mock.call(Configuration.section_name("build", "x86_64")),
|
||||
mock.call("repository"),
|
||||
mock.call(Configuration.section_name("sign", "x86_64")),
|
||||
mock.call(Configuration.section_name("web", "x86_64")),
|
||||
])
|
||||
set_mock.assert_has_calls([
|
||||
mock.call("build", "build_command", str(command)),
|
||||
mock.call(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
|
||||
mock.call("repository", "name", args.repository),
|
||||
mock.call(Configuration.section_name("sign", "x86_64"), "target", " ".join(args.sign_target)),
|
||||
mock.call(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
||||
mock.call(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
||||
])
|
||||
write_mock.assert_called_once()
|
||||
|
||||
|
@ -52,7 +52,8 @@ def test_subparsers_setup(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
setup command must imply lock, no_report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "setup", "--packager", "John Doe <john@doe.com>"])
|
||||
args = parser.parse_args(["-a", "x86_64", "setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone"])
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert args.unsafe
|
||||
|
@ -9,7 +9,7 @@ def test_repository_sign_args_1(gpg_with_key: GPG) -> None:
|
||||
"""
|
||||
must generate correct sign args
|
||||
"""
|
||||
gpg_with_key.targets = {SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Repository}
|
||||
assert gpg_with_key.repository_sign_args
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ def test_repository_sign_args_2(gpg_with_key: GPG) -> None:
|
||||
"""
|
||||
must generate correct sign args
|
||||
"""
|
||||
gpg_with_key.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
assert gpg_with_key.repository_sign_args
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ def test_repository_sign_args_skip_2(gpg_with_key: GPG) -> None:
|
||||
"""
|
||||
must return empty args if it is not set
|
||||
"""
|
||||
gpg_with_key.targets = {SignSettings.SignPackages}
|
||||
gpg_with_key.targets = {SignSettings.Packages}
|
||||
assert not gpg_with_key.repository_sign_args
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ def test_repository_sign_args_skip_3(gpg: GPG) -> None:
|
||||
"""
|
||||
must return empty args if it is not set
|
||||
"""
|
||||
gpg.targets = {SignSettings.SignRepository}
|
||||
gpg.targets = {SignSettings.Repository}
|
||||
assert not gpg.repository_sign_args
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ def test_repository_sign_args_skip_4(gpg: GPG) -> None:
|
||||
"""
|
||||
must return empty args if it is not set
|
||||
"""
|
||||
gpg.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
assert not gpg.repository_sign_args
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ def test_sign_package_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
|
||||
result = [Path("a"), Path("a.sig")]
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
|
||||
|
||||
gpg_with_key.targets = {SignSettings.SignPackages}
|
||||
gpg_with_key.targets = {SignSettings.Packages}
|
||||
assert gpg_with_key.sign_package(Path("a"), "a") == result
|
||||
process_mock.assert_called_once()
|
||||
|
||||
@ -90,7 +90,7 @@ def test_sign_package_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
|
||||
result = [Path("a"), Path("a.sig")]
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
|
||||
|
||||
gpg_with_key.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
assert gpg_with_key.sign_package(Path("a"), "a") == result
|
||||
process_mock.assert_called_once()
|
||||
|
||||
@ -110,7 +110,7 @@ def test_sign_package_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
|
||||
must not sign package if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg_with_key.targets = {SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Repository}
|
||||
gpg_with_key.sign_package(Path("a"), "a")
|
||||
process_mock.assert_not_called()
|
||||
|
||||
@ -120,7 +120,7 @@ def test_sign_package_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
must not sign package if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg.targets = {SignSettings.SignPackages}
|
||||
gpg.targets = {SignSettings.Packages}
|
||||
gpg.sign_package(Path("a"), "a")
|
||||
process_mock.assert_not_called()
|
||||
|
||||
@ -130,7 +130,7 @@ def test_sign_package_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
must not sign package if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
gpg.sign_package(Path("a"), "a")
|
||||
process_mock.assert_not_called()
|
||||
|
||||
@ -142,7 +142,7 @@ def test_sign_repository_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
|
||||
result = [Path("a"), Path("a.sig")]
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
|
||||
|
||||
gpg_with_key.targets = {SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Repository}
|
||||
assert gpg_with_key.sign_repository(Path("a")) == result
|
||||
process_mock.assert_called_once()
|
||||
|
||||
@ -154,7 +154,7 @@ def test_sign_repository_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
|
||||
result = [Path("a"), Path("a.sig")]
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
|
||||
|
||||
gpg_with_key.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
assert gpg_with_key.sign_repository(Path("a")) == result
|
||||
process_mock.assert_called_once()
|
||||
|
||||
@ -174,7 +174,7 @@ def test_sign_repository_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> Non
|
||||
must not sign repository if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg_with_key.targets = {SignSettings.SignPackages}
|
||||
gpg_with_key.targets = {SignSettings.Packages}
|
||||
gpg_with_key.sign_repository(Path("a"))
|
||||
process_mock.assert_not_called()
|
||||
|
||||
@ -184,7 +184,7 @@ def test_sign_repository_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
must not sign repository if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg.targets = {SignSettings.SignRepository}
|
||||
gpg.targets = {SignSettings.Repository}
|
||||
gpg.sign_repository(Path("a"))
|
||||
process_mock.assert_not_called()
|
||||
|
||||
@ -194,6 +194,6 @@ def test_sign_repository_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
|
||||
must not sign repository if it is not set
|
||||
"""
|
||||
process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
|
||||
gpg.targets = {SignSettings.SignPackages, SignSettings.SignRepository}
|
||||
gpg.targets = {SignSettings.Packages, SignSettings.Repository}
|
||||
gpg.sign_repository(Path("a"))
|
||||
process_mock.assert_not_called()
|
||||
|
@ -16,11 +16,11 @@ def test_from_option_valid() -> None:
|
||||
"""
|
||||
must return value from valid options
|
||||
"""
|
||||
assert SignSettings.from_option("package") == SignSettings.SignPackages
|
||||
assert SignSettings.from_option("PACKAGE") == SignSettings.SignPackages
|
||||
assert SignSettings.from_option("packages") == SignSettings.SignPackages
|
||||
assert SignSettings.from_option("sign-package") == SignSettings.SignPackages
|
||||
assert SignSettings.from_option("package") == SignSettings.Packages
|
||||
assert SignSettings.from_option("PACKAGE") == SignSettings.Packages
|
||||
assert SignSettings.from_option("packages") == SignSettings.Packages
|
||||
assert SignSettings.from_option("sign-package") == SignSettings.Packages
|
||||
|
||||
assert SignSettings.from_option("repository") == SignSettings.SignRepository
|
||||
assert SignSettings.from_option("REPOSITORY") == SignSettings.SignRepository
|
||||
assert SignSettings.from_option("sign-repository") == SignSettings.SignRepository
|
||||
assert SignSettings.from_option("repository") == SignSettings.Repository
|
||||
assert SignSettings.from_option("REPOSITORY") == SignSettings.Repository
|
||||
assert SignSettings.from_option("sign-repository") == SignSettings.Repository
|
||||
|
@ -34,12 +34,10 @@ def test_run(application: web.Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run application
|
||||
"""
|
||||
host = "localhost"
|
||||
port = 8080
|
||||
application["configuration"].set("web", "host", host)
|
||||
application["configuration"].set("web", "port", str(port))
|
||||
run_application_mock = mocker.patch("aiohttp.web.run_app")
|
||||
|
||||
run_server(application)
|
||||
run_application_mock.assert_called_with(application, host=host, port=port,
|
||||
run_application_mock.assert_called_with(application, host="0.0.0.0", port=port,
|
||||
handle_signals=False, access_log=pytest.helpers.anyvar(int))
|
||||
|
@ -43,4 +43,5 @@ bucket =
|
||||
command = aws s3 sync --quiet --delete
|
||||
|
||||
[web]
|
||||
host = 0.0.0.0
|
||||
templates = ../web/templates
|
Reference in New Issue
Block a user