ahriman/tests/ahriman/application/handlers/test_handler_restore.py
Evgenii Alekseev 4daff81d5f Docstring update (#58)
* 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
2022-04-17 20:25:28 +03:00

44 lines
1.2 KiB
Python

import argparse
from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.application.handlers import Restore
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.path = Path("result.tar.gz")
args.output = Path.cwd()
return args
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run command
"""
args = _default_args(args)
tarfile = MagicMock()
extract_mock = tarfile.__enter__.return_value = MagicMock()
mocker.patch("tarfile.TarFile.__new__", return_value=tarfile)
Restore.run(args, "x86_64", configuration, True, False)
extract_mock.extractall.assert_called_once_with(path=args.output)
def test_disallow_auto_architecture_run() -> None:
"""
must not allow multi architecture run
"""
assert not Restore.ALLOW_AUTO_ARCHITECTURE_RUN