mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 14:51:43 +00:00
* migrate docstrings from reST to google format * add raises note Also change behaviour of the `from_option` method to fallback to disabled instead of raising exception on unknown option * fix part of warnings for sphinx * make identation a bit more readable * review fixes * add verbose description for properties to make them parsed by sphinx extenstion * add demo sphinx generator
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
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
|
|
|
|
Args:
|
|
args(argparse.Namespace): command line arguments fixture
|
|
|
|
Returns:
|
|
argparse.Namespace: 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"])
|
|
|
|
|
|
def test_disallow_auto_architecture_run() -> None:
|
|
"""
|
|
must not allow multi architecture run
|
|
"""
|
|
assert not Help.ALLOW_AUTO_ARCHITECTURE_RUN
|