mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-22 18:29:56 +00:00
do not spawn process for single architecture run
This commit is contained in:
@ -6,7 +6,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Handler
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import MissingArchitecture
|
||||
from ahriman.core.exceptions import MissingArchitecture, MultipleArchitecture
|
||||
|
||||
|
||||
def test_call(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
@ -44,6 +44,29 @@ def test_execute(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
starmap_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_execute_multiple_not_supported(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise an exception if multiple architectures are not supported by the handler
|
||||
"""
|
||||
args.architecture = ["i686", "x86_64"]
|
||||
args.command = "web"
|
||||
mocker.patch.object(Handler, "ALLOW_MULTI_ARCHITECTURE_RUN", False)
|
||||
|
||||
with pytest.raises(MultipleArchitecture):
|
||||
Handler.execute(args)
|
||||
|
||||
|
||||
def test_execute_single(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run execution in current process if only one architecture supplied
|
||||
"""
|
||||
args.architecture = ["x86_64"]
|
||||
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
||||
|
||||
Handler.execute(args)
|
||||
starmap_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_extract_architectures(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate list of available architectures
|
||||
|
@ -29,3 +29,10 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
Web.run(args, "x86_64", configuration, True)
|
||||
setup_mock.assert_called_once()
|
||||
run_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_disallow_multi_architecture_run() -> None:
|
||||
"""
|
||||
must not allow multi architecture run
|
||||
"""
|
||||
assert not Web.ALLOW_MULTI_ARCHITECTURE_RUN
|
||||
|
Reference in New Issue
Block a user