mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-25 03:39:55 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
db195391e4 | |||
59f2992559 |
@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Evgeniy Alekseev
|
# Maintainer: Evgeniy Alekseev
|
||||||
|
|
||||||
pkgname='ahriman'
|
pkgname='ahriman'
|
||||||
pkgver=1.4.0
|
pkgver=1.4.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="ArcH Linux ReposItory MANager"
|
pkgdesc="ArcH Linux ReposItory MANager"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
@ -95,7 +95,7 @@ def _set_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser.add_argument("--source", help="package source", choices=PackageSource, type=PackageSource,
|
parser.add_argument("--source", help="package source", choices=PackageSource, type=PackageSource,
|
||||||
default=PackageSource.Auto)
|
default=PackageSource.Auto)
|
||||||
parser.add_argument("--without-dependencies", help="do not add dependencies", action="store_true")
|
parser.add_argument("--without-dependencies", help="do not add dependencies", action="store_true")
|
||||||
parser.set_defaults(handler=handlers.Add, architecture=[])
|
parser.set_defaults(handler=handlers.Add)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ def _set_check_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("package", help="filter check by package base", nargs="*")
|
parser.add_argument("package", help="filter check by package base", nargs="*")
|
||||||
parser.add_argument("--no-vcs", help="do not check VCS packages", action="store_true")
|
parser.add_argument("--no-vcs", help="do not check VCS packages", action="store_true")
|
||||||
parser.set_defaults(handler=handlers.Update, architecture=[], no_aur=False, no_manual=True, dry_run=True)
|
parser.set_defaults(handler=handlers.Update, no_aur=False, no_manual=True, dry_run=True)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ def _set_clean_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser.add_argument("--no-chroot", help="do not clear build chroot", action="store_true")
|
parser.add_argument("--no-chroot", help="do not clear build chroot", action="store_true")
|
||||||
parser.add_argument("--no-manual", help="do not clear directory with manually added packages", action="store_true")
|
parser.add_argument("--no-manual", help="do not clear directory with manually added packages", action="store_true")
|
||||||
parser.add_argument("--no-packages", help="do not clear directory with built packages", action="store_true")
|
parser.add_argument("--no-packages", help="do not clear directory with built packages", action="store_true")
|
||||||
parser.set_defaults(handler=handlers.Clean, architecture=[], no_log=True, unsafe=True)
|
parser.set_defaults(handler=handlers.Clean, no_log=True, unsafe=True)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ def _set_rebuild_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser = root.add_parser("rebuild", help="rebuild repository", description="rebuild whole repository",
|
parser = root.add_parser("rebuild", help="rebuild repository", description="rebuild whole repository",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("--depends-on", help="only rebuild packages that depend on specified package", action="append")
|
parser.add_argument("--depends-on", help="only rebuild packages that depend on specified package", action="append")
|
||||||
parser.set_defaults(handler=handlers.Rebuild, architecture=[])
|
parser.set_defaults(handler=handlers.Rebuild)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ def _set_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser = root.add_parser("remove", help="remove package", description="remove package",
|
parser = root.add_parser("remove", help="remove package", description="remove package",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("package", help="package name or base", nargs="+")
|
parser.add_argument("package", help="package name or base", nargs="+")
|
||||||
parser.set_defaults(handler=handlers.Remove, architecture=[])
|
parser.set_defaults(handler=handlers.Remove)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ def _set_remove_unknown_parser(root: SubParserAction) -> argparse.ArgumentParser
|
|||||||
description="remove packages which are missing in AUR",
|
description="remove packages which are missing in AUR",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("--dry-run", help="just perform check for packages without removal", action="store_true")
|
parser.add_argument("--dry-run", help="just perform check for packages without removal", action="store_true")
|
||||||
parser.set_defaults(handler=handlers.RemoveUnknown, architecture=[])
|
parser.set_defaults(handler=handlers.RemoveUnknown)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ def _set_report_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser = root.add_parser("report", help="generate report", description="generate report",
|
parser = root.add_parser("report", help="generate report", description="generate report",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("target", help="target to generate report", nargs="*")
|
parser.add_argument("target", help="target to generate report", nargs="*")
|
||||||
parser.set_defaults(handler=handlers.Report, architecture=[])
|
parser.set_defaults(handler=handlers.Report)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ def _set_sign_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser = root.add_parser("sign", help="sign packages", description="(re-)sign packages and repository database",
|
parser = root.add_parser("sign", help="sign packages", description="(re-)sign packages and repository database",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("package", help="sign only specified packages", nargs="*")
|
parser.add_argument("package", help="sign only specified packages", nargs="*")
|
||||||
parser.set_defaults(handler=handlers.Sign, architecture=[])
|
parser.set_defaults(handler=handlers.Sign)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ def _set_sync_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser = root.add_parser("sync", help="sync repository", description="sync packages to remote server",
|
parser = root.add_parser("sync", help="sync repository", description="sync packages to remote server",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument("target", help="target to sync", nargs="*")
|
parser.add_argument("target", help="target to sync", nargs="*")
|
||||||
parser.set_defaults(handler=handlers.Sync, architecture=[])
|
parser.set_defaults(handler=handlers.Sync)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ def _set_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser.add_argument("--no-aur", help="do not check for AUR updates. Implies --no-vcs", action="store_true")
|
parser.add_argument("--no-aur", help="do not check for AUR updates. Implies --no-vcs", action="store_true")
|
||||||
parser.add_argument("--no-manual", help="do not include manual updates", action="store_true")
|
parser.add_argument("--no-manual", help="do not include manual updates", action="store_true")
|
||||||
parser.add_argument("--no-vcs", help="do not check VCS packages", action="store_true")
|
parser.add_argument("--no-vcs", help="do not check VCS packages", action="store_true")
|
||||||
parser.set_defaults(handler=handlers.Update, architecture=[])
|
parser.set_defaults(handler=handlers.Update)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ class Dump(Handler):
|
|||||||
dump configuration handler
|
dump configuration handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
|
|
||||||
_print = print
|
_print = print
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -34,9 +34,11 @@ from ahriman.models.repository_paths import RepositoryPaths
|
|||||||
class Handler:
|
class Handler:
|
||||||
"""
|
"""
|
||||||
base handler class for command callbacks
|
base handler class for command callbacks
|
||||||
|
:cvar ALLOW_AUTO_ARCHITECTURE_RUN: allow to define architecture from existing repositories
|
||||||
:cvar ALLOW_MULTI_ARCHITECTURE_RUN: allow to run with multiple architectures
|
:cvar ALLOW_MULTI_ARCHITECTURE_RUN: allow to run with multiple architectures
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = True
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = True
|
ALLOW_MULTI_ARCHITECTURE_RUN = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -85,9 +87,11 @@ class Handler:
|
|||||||
:param args: command line args
|
:param args: command line args
|
||||||
:return: list of architectures for which tree is created
|
:return: list of architectures for which tree is created
|
||||||
"""
|
"""
|
||||||
if args.architecture is None:
|
if not cls.ALLOW_AUTO_ARCHITECTURE_RUN and args.architecture is None:
|
||||||
|
# for some parsers (e.g. config) we need to run with specific architecture
|
||||||
|
# for those cases architecture must be set explicitly
|
||||||
raise MissingArchitecture(args.command)
|
raise MissingArchitecture(args.command)
|
||||||
if args.architecture:
|
if args.architecture: # architecture is specified explicitly
|
||||||
return set(args.architecture)
|
return set(args.architecture)
|
||||||
|
|
||||||
config = Configuration()
|
config = Configuration()
|
||||||
@ -96,7 +100,7 @@ class Handler:
|
|||||||
root = config.getpath("repository", "root") # pylint: disable=assignment-from-no-return
|
root = config.getpath("repository", "root") # pylint: disable=assignment-from-no-return
|
||||||
architectures = RepositoryPaths.known_architectures(root)
|
architectures = RepositoryPaths.known_architectures(root)
|
||||||
|
|
||||||
if not architectures:
|
if not architectures: # well we did not find anything
|
||||||
raise MissingArchitecture(args.command)
|
raise MissingArchitecture(args.command)
|
||||||
return architectures
|
return architectures
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ class Init(Handler):
|
|||||||
repository init handler
|
repository init handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -31,6 +31,8 @@ class KeyImport(Handler):
|
|||||||
key import packages handler
|
key import packages handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False # it should be called only as "no-architecture"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -31,6 +31,8 @@ class Search(Handler):
|
|||||||
packages search handler
|
packages search handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False # it should be called only as "no-architecture"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -37,6 +37,8 @@ class Setup(Handler):
|
|||||||
:cvar SUDOERS_PATH: path to sudoers.d include configuration
|
:cvar SUDOERS_PATH: path to sudoers.d include configuration
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
|
|
||||||
ARCHBUILD_COMMAND_PATH = Path("/usr/bin/archbuild")
|
ARCHBUILD_COMMAND_PATH = Path("/usr/bin/archbuild")
|
||||||
BIN_DIR_PATH = Path("/usr/local/bin")
|
BIN_DIR_PATH = Path("/usr/local/bin")
|
||||||
MIRRORLIST_PATH = Path("/etc/pacman.d/mirrorlist")
|
MIRRORLIST_PATH = Path("/etc/pacman.d/mirrorlist")
|
||||||
|
@ -33,6 +33,8 @@ class Status(Handler):
|
|||||||
package status handler
|
package status handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -32,6 +32,8 @@ class StatusUpdate(Handler):
|
|||||||
status update handler
|
status update handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -35,6 +35,8 @@ class User(Handler):
|
|||||||
user management handler
|
user management handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False # it should be called only as "no-architecture"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str,
|
||||||
configuration: Configuration, no_report: bool) -> None:
|
configuration: Configuration, no_report: bool) -> None:
|
||||||
|
@ -31,6 +31,7 @@ class Web(Handler):
|
|||||||
web server handler
|
web server handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ALLOW_AUTO_ARCHITECTURE_RUN = False
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # required to be able to spawn external processes
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # required to be able to spawn external processes
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -17,4 +17,4 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
__version__ = "1.4.0"
|
__version__ = "1.4.1"
|
||||||
|
@ -27,7 +27,7 @@ def args() -> argparse.Namespace:
|
|||||||
fixture for command line arguments
|
fixture for command line arguments
|
||||||
:return: command line arguments test instance
|
:return: command line arguments test instance
|
||||||
"""
|
"""
|
||||||
return argparse.Namespace(lock=None, force=False, unsafe=False, no_report=True)
|
return argparse.Namespace(architecture=None, lock=None, force=False, unsafe=False, no_report=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -71,7 +71,6 @@ def test_extract_architectures(args: argparse.Namespace, configuration: Configur
|
|||||||
"""
|
"""
|
||||||
must generate list of available architectures
|
must generate list of available architectures
|
||||||
"""
|
"""
|
||||||
args.architecture = []
|
|
||||||
args.configuration = configuration.path
|
args.configuration = configuration.path
|
||||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||||
|
|
||||||
@ -84,7 +83,6 @@ def test_extract_architectures_empty(args: argparse.Namespace, configuration: Co
|
|||||||
"""
|
"""
|
||||||
must raise exception if no available architectures found
|
must raise exception if no available architectures found
|
||||||
"""
|
"""
|
||||||
args.architecture = []
|
|
||||||
args.command = "config"
|
args.command = "config"
|
||||||
args.configuration = configuration.path
|
args.configuration = configuration.path
|
||||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
||||||
@ -93,12 +91,12 @@ def test_extract_architectures_empty(args: argparse.Namespace, configuration: Co
|
|||||||
Handler.extract_architectures(args)
|
Handler.extract_architectures(args)
|
||||||
|
|
||||||
|
|
||||||
def test_extract_architectures_exception(args: argparse.Namespace) -> None:
|
def test_extract_architectures_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must raise exception on missing architectures
|
must raise exception on missing architectures
|
||||||
"""
|
"""
|
||||||
args.command = "config"
|
args.command = "config"
|
||||||
args.architecture = None
|
mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
|
||||||
with pytest.raises(MissingArchitecture):
|
with pytest.raises(MissingArchitecture):
|
||||||
Handler.extract_architectures(args)
|
Handler.extract_architectures(args)
|
||||||
|
|
||||||
|
@ -18,3 +18,10 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
Dump.run(args, "x86_64", configuration, True)
|
Dump.run(args, "x86_64", configuration, True)
|
||||||
application_mock.assert_called_once()
|
application_mock.assert_called_once()
|
||||||
print_mock.assert_called()
|
print_mock.assert_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Dump.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -16,3 +16,10 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
Init.run(args, "x86_64", configuration, True)
|
Init.run(args, "x86_64", configuration, True)
|
||||||
create_tree_mock.assert_called_once()
|
create_tree_mock.assert_called_once()
|
||||||
init_mock.assert_called_once()
|
init_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Init.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -27,3 +27,10 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
|
|
||||||
KeyImport.run(args, "x86_64", configuration, True)
|
KeyImport.run(args, "x86_64", configuration, True)
|
||||||
application_mock.assert_called_once()
|
application_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not KeyImport.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -53,3 +53,10 @@ def test_log_fn(args: argparse.Namespace, configuration: Configuration, aur_pack
|
|||||||
|
|
||||||
Search.run(args, "x86_64", configuration, True)
|
Search.run(args, "x86_64", configuration, True)
|
||||||
print_mock.assert_called() # we don't really care about call details tbh
|
print_mock.assert_called() # we don't really care about call details tbh
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Search.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -149,3 +149,10 @@ def test_create_executable(args: argparse.Namespace, mocker: MockerFixture) -> N
|
|||||||
Setup.create_executable(args.build_command, "x86_64")
|
Setup.create_executable(args.build_command, "x86_64")
|
||||||
symlink_text_mock.assert_called_once()
|
symlink_text_mock.assert_called_once()
|
||||||
unlink_text_mock.assert_called_once()
|
unlink_text_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Setup.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -81,3 +81,10 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
|||||||
|
|
||||||
Status.run(args, "x86_64", configuration, True)
|
Status.run(args, "x86_64", configuration, True)
|
||||||
load_mock.assert_called_once()
|
load_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Status.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -86,3 +86,10 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
|||||||
|
|
||||||
StatusUpdate.run(args, "x86_64", configuration, True)
|
StatusUpdate.run(args, "x86_64", configuration, True)
|
||||||
load_mock.assert_called_once()
|
load_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not StatusUpdate.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -257,3 +257,10 @@ def test_write_configuration_not_loaded(configuration: Configuration, mocker: Mo
|
|||||||
User.write_configuration(configuration, secure=True)
|
User.write_configuration(configuration, secure=True)
|
||||||
write_mock.assert_not_called()
|
write_mock.assert_not_called()
|
||||||
chmod_mock.assert_not_called()
|
chmod_mock.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not User.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
@ -31,6 +31,13 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
run_mock.assert_called_once()
|
run_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_disallow_auto_architecture_run() -> None:
|
||||||
|
"""
|
||||||
|
must not allow multi architecture run
|
||||||
|
"""
|
||||||
|
assert not Web.ALLOW_AUTO_ARCHITECTURE_RUN
|
||||||
|
|
||||||
|
|
||||||
def test_disallow_multi_architecture_run() -> None:
|
def test_disallow_multi_architecture_run() -> None:
|
||||||
"""
|
"""
|
||||||
must not allow multi architecture run
|
must not allow multi architecture run
|
||||||
|
@ -41,43 +41,64 @@ def test_multiple_architectures(parser: argparse.ArgumentParser) -> None:
|
|||||||
must accept multiple architectures
|
must accept multiple architectures
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["-a", "x86_64", "-a", "i686", "config"])
|
args = parser.parse_args(["-a", "x86_64", "-a", "i686", "config"])
|
||||||
assert len(args.architecture) == 2
|
assert args.architecture == ["x86_64", "i686"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_add(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_add_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
add command must imply empty architectures list
|
add command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["add", "ahriman"])
|
args = parser.parse_args(["add", "ahriman"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "add", "ahriman"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_check(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_check(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
check command must imply empty architecture list, no-aur, no-manual and dry-run
|
check command must imply no-aur, no-manual and dry-run
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["check"])
|
args = parser.parse_args(["check"])
|
||||||
assert args.architecture == []
|
|
||||||
assert not args.no_aur
|
assert not args.no_aur
|
||||||
assert args.no_manual
|
assert args.no_manual
|
||||||
assert args.dry_run
|
assert args.dry_run
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_check_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
check command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["check"])
|
||||||
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "check"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_clean(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_clean(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
clean command must imply empty architectures list, unsafe and no-log
|
clean command must imply unsafe and no-log
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["clean"])
|
args = parser.parse_args(["clean"])
|
||||||
assert args.architecture == []
|
|
||||||
assert args.no_log
|
assert args.no_log
|
||||||
assert args.unsafe
|
assert args.unsafe
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_clean_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
clean command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["clean"])
|
||||||
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "clean"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_config(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_config(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
config command must imply lock, no-log, no-report and unsafe
|
config command must imply lock, no-log, no-report and unsafe
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["config"])
|
args = parser.parse_args(["-a", "x86_64", "config"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.lock is None
|
assert args.lock is None
|
||||||
assert args.no_log
|
assert args.no_log
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
@ -88,7 +109,8 @@ def test_subparsers_init(parser: argparse.ArgumentParser) -> None:
|
|||||||
"""
|
"""
|
||||||
init command must imply no_report
|
init command must imply no_report
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["init"])
|
args = parser.parse_args(["-a", "x86_64", "init"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
|
|
||||||
|
|
||||||
@ -102,36 +124,42 @@ def test_subparsers_key_import(parser: argparse.ArgumentParser) -> None:
|
|||||||
assert args.no_report
|
assert args.no_report
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_rebuild(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_key_import_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
rebuild command must imply empty architectures list
|
check command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "key-import", "key"])
|
||||||
|
assert args.architecture == [""]
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_rebuild_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
rebuild command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["rebuild"])
|
args = parser.parse_args(["rebuild"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "rebuild"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_remove(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_remove_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
remove command must imply empty architectures list
|
remove command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["remove", "ahriman"])
|
args = parser.parse_args(["remove", "ahriman"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "remove", "ahriman"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_remove_unknown(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_report_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
remove-unknown command must imply empty architectures list
|
report command must correctly parse architecture list
|
||||||
"""
|
|
||||||
args = parser.parse_args(["remove-unknown"])
|
|
||||||
assert args.architecture == []
|
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_report(parser: argparse.ArgumentParser) -> None:
|
|
||||||
"""
|
|
||||||
report command must imply empty architectures list
|
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["report"])
|
args = parser.parse_args(["report"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "report"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_search(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_search(parser: argparse.ArgumentParser) -> None:
|
||||||
@ -146,12 +174,21 @@ def test_subparsers_search(parser: argparse.ArgumentParser) -> None:
|
|||||||
assert args.unsafe
|
assert args.unsafe
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_search_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
search command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "search", "ahriman"])
|
||||||
|
assert args.architecture == [""]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_setup(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_setup(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
setup command must imply lock, no-log, no-report and unsafe
|
setup command must imply lock, no-log, 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"])
|
"--repository", "aur-clone"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.lock is None
|
assert args.lock is None
|
||||||
assert args.no_log
|
assert args.no_log
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
@ -180,12 +217,14 @@ def test_subparsers_setup_option_sign_target(parser: argparse.ArgumentParser) ->
|
|||||||
assert all(isinstance(target, SignSettings) for target in args.sign_target)
|
assert all(isinstance(target, SignSettings) for target in args.sign_target)
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_sign(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_sign_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
sign command must imply empty architectures list
|
sign command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["sign"])
|
args = parser.parse_args(["sign"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "sign"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_status(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_status(parser: argparse.ArgumentParser) -> None:
|
||||||
@ -193,6 +232,7 @@ def test_subparsers_status(parser: argparse.ArgumentParser) -> None:
|
|||||||
status command must imply lock, no-log, no-report and unsafe
|
status command must imply lock, no-log, no-report and unsafe
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["-a", "x86_64", "status"])
|
args = parser.parse_args(["-a", "x86_64", "status"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.lock is None
|
assert args.lock is None
|
||||||
assert args.no_log
|
assert args.no_log
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
@ -204,6 +244,7 @@ def test_subparsers_status_update(parser: argparse.ArgumentParser) -> None:
|
|||||||
status-update command must imply lock, no-log, no-report and unsafe
|
status-update command must imply lock, no-log, no-report and unsafe
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["-a", "x86_64", "status-update"])
|
args = parser.parse_args(["-a", "x86_64", "status-update"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.lock is None
|
assert args.lock is None
|
||||||
assert args.no_log
|
assert args.no_log
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
@ -220,20 +261,24 @@ def test_subparsers_status_update_option_status(parser: argparse.ArgumentParser)
|
|||||||
assert isinstance(args.status, BuildStatusEnum)
|
assert isinstance(args.status, BuildStatusEnum)
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_sync(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_sync_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
sync command must imply empty architectures list
|
sync command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["sync"])
|
args = parser.parse_args(["sync"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "sync"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_update(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_update_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
update command must imply empty architectures list
|
update command must correctly parse architecture list
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["update"])
|
args = parser.parse_args(["update"])
|
||||||
assert args.architecture == []
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "update"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_user(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_user(parser: argparse.ArgumentParser) -> None:
|
||||||
@ -248,6 +293,14 @@ def test_subparsers_user(parser: argparse.ArgumentParser) -> None:
|
|||||||
assert args.unsafe
|
assert args.unsafe
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_user_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
user command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "user", "username"])
|
||||||
|
assert args.architecture == [""]
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_user_option_role(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_user_option_role(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
user command must convert role option to useraccess instance
|
user command must convert role option to useraccess instance
|
||||||
@ -263,6 +316,7 @@ def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
|
|||||||
web command must imply lock, no_report and parser
|
web command must imply lock, no_report and parser
|
||||||
"""
|
"""
|
||||||
args = parser.parse_args(["-a", "x86_64", "web"])
|
args = parser.parse_args(["-a", "x86_64", "web"])
|
||||||
|
assert args.architecture == ["x86_64"]
|
||||||
assert args.lock is None
|
assert args.lock is None
|
||||||
assert args.no_report
|
assert args.no_report
|
||||||
assert args.parser is not None and args.parser()
|
assert args.parser is not None and args.parser()
|
||||||
|
Reference in New Issue
Block a user