mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-05-01 02:37:17 +00:00
Compare commits
2 Commits
6fcb5449c3
...
28afcde3fa
Author | SHA1 | Date | |
---|---|---|---|
28afcde3fa | |||
62ae3ada4a |
@ -85,7 +85,7 @@ autoclass_content = "both"
|
||||
|
||||
autodoc_member_order = "groupwise"
|
||||
|
||||
autodoc_mock_imports = ["pyalpm"]
|
||||
autodoc_mock_imports = ["cryptography", "pyalpm"]
|
||||
|
||||
autodoc_default_options = {
|
||||
"no-undoc-members": True,
|
||||
|
@ -90,7 +90,7 @@ def _parser() -> argparse.ArgumentParser:
|
||||
type=int, default=-1)
|
||||
parser.add_argument("-V", "--version", action="version", version=__version__)
|
||||
|
||||
subparsers = parser.add_subparsers(title="command", help="command to run", dest="command", required=True)
|
||||
subparsers = parser.add_subparsers(title="command", help="command to run", dest="command")
|
||||
|
||||
_set_aur_search_parser(subparsers)
|
||||
_set_help_parser(subparsers)
|
||||
@ -1016,5 +1016,8 @@ def run() -> int:
|
||||
args_parser = _parser()
|
||||
args = args_parser.parse_args()
|
||||
|
||||
if args.command is None: # in case of empty command we would like to print help message
|
||||
args_parser.exit(status=2, message=args_parser.format_help())
|
||||
|
||||
handler: handlers.Handler = args.handler
|
||||
return handler.execute(args)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
@ -841,8 +842,20 @@ def test_run(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
application must be run
|
||||
"""
|
||||
args.architecture = "x86_64"
|
||||
args.command = ""
|
||||
args.handler = Handler
|
||||
|
||||
mocker.patch("argparse.ArgumentParser.parse_args", return_value=args)
|
||||
|
||||
assert ahriman.run() == 1
|
||||
|
||||
|
||||
def test_run_without_command(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must show help message if run without commands
|
||||
"""
|
||||
args.command = None
|
||||
mocker.patch("argparse.ArgumentParser.parse_args", return_value=args)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
ahriman.run()
|
||||
|
Loading…
Reference in New Issue
Block a user