do not use set_defaults for architecture arguments

according to the source code defaults always updates the values
dictionary. This in this specific case it is impossible to override the
value it will be always empty list.

In order to handle it we are adding another property to the Handler
class which allows to run with None architecture list.

This particular set_defaults behaviour is still useful for other cases
when we have to run command without any specific architecture
This commit is contained in:
2021-10-03 00:59:24 +03:00
parent 444da87fdc
commit 1192f12f91
23 changed files with 190 additions and 54 deletions

View File

@ -71,7 +71,6 @@ def test_extract_architectures(args: argparse.Namespace, configuration: Configur
"""
must generate list of available architectures
"""
args.architecture = []
args.configuration = configuration.path
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
@ -84,7 +83,6 @@ def test_extract_architectures_empty(args: argparse.Namespace, configuration: Co
"""
must raise exception if no available architectures found
"""
args.architecture = []
args.command = "config"
args.configuration = configuration.path
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
@ -93,12 +91,12 @@ def test_extract_architectures_empty(args: argparse.Namespace, configuration: Co
Handler.extract_architectures(args)
def test_extract_architectures_exception(args: argparse.Namespace) -> None:
def test_extract_architectures_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
"""
must raise exception on missing architectures
"""
args.command = "config"
args.architecture = None
mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
with pytest.raises(MissingArchitecture):
Handler.extract_architectures(args)