mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
add help command
This commit is contained in:
41
tests/ahriman/application/handlers/test_handler_help.py
Normal file
41
tests/ahriman/application/handlers/test_handler_help.py
Normal file
@ -0,0 +1,41 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.ahriman import _parser
|
||||
from ahriman.application.handlers import Help
|
||||
from ahriman.core.configuration import Configuration
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
:param args: command line arguments fixture
|
||||
:return: generated arguments for these test cases
|
||||
"""
|
||||
args.parser = _parser
|
||||
args.command = None
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, True, False)
|
||||
parse_mock.assert_called_once_with(["--help"])
|
||||
|
||||
|
||||
def test_run_command(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command for specific subcommand
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.command = "aur-search"
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, True, False)
|
||||
parse_mock.assert_called_once_with(["aur-search", "--help"])
|
@ -65,6 +65,27 @@ def test_subparsers_aur_search_architecture(parser: argparse.ArgumentParser) ->
|
||||
assert args.architecture == [""]
|
||||
|
||||
|
||||
def test_subparsers_help(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help command must imply architecture list, lock, no-report, quiet, unsafe and parser
|
||||
"""
|
||||
args = parser.parse_args(["help"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
|
||||
def test_subparsers_help_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help"])
|
||||
assert args.architecture == [""]
|
||||
|
||||
|
||||
def test_subparsers_help_commands_unsafe(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help-commands-unsafe command must imply architecture list, lock, no-report, quiet, unsafe and parser
|
||||
@ -80,7 +101,7 @@ def test_subparsers_help_commands_unsafe(parser: argparse.ArgumentParser) -> Non
|
||||
|
||||
def test_subparsers_help_commands_unsafe_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help-ommands-unsafe command must correctly parse architecture list
|
||||
help-commands-unsafe command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "help-commands-unsafe"])
|
||||
assert args.architecture == [""]
|
||||
|
Reference in New Issue
Block a user