no- + fullname == false

This commit is contained in:
Emmanuel Garette 2019-07-30 21:50:48 +02:00
parent 57e85b49eb
commit 74215a6f80
2 changed files with 33 additions and 3 deletions

View File

@ -186,6 +186,34 @@ def test_leadership_modif_follower_bool_false(json):
assert config.value.dict() == output assert config.value.dict() == output
def test_leadership_modif_follower_bool_true_fullname(json):
output = {'leader.leader': ['192.168.0.1'],
'leader.follower': [None],
'leader.follower_boolean': [True],
'leader.follower_choice': [None],
'leader.follower_integer': [None],
'leader.follower_submulti': [[]]}
config = get_config(json)
parser = TiramisuCmdlineParser(config, 'prog.py', fullpath=False)
parser.parse_args(['--follower_boolean', '0'])
assert config.value.dict() == output
def test_leadership_modif_follower_bool_false_fullname(json):
output = {'leader.leader': ['192.168.0.1'],
'leader.follower': [None],
'leader.follower_boolean': [False],
'leader.follower_choice': [None],
'leader.follower_integer': [None],
'leader.follower_submulti': [[]]}
config = get_config(json)
parser = TiramisuCmdlineParser(config, 'prog.py', fullpath=False)
parser.parse_args(['--no-follower_boolean', '0'])
assert config.value.dict() == output
def test_leadership_modif_follower_choice(json): def test_leadership_modif_follower_choice(json):
output = {'leader.leader': ['192.168.0.1'], output = {'leader.leader': ['192.168.0.1'],
'leader.follower': [None], 'leader.follower': [None],

View File

@ -20,7 +20,7 @@ from gettext import gettext as _
try: try:
from tiramisu import Config from tiramisu import Config
from tiramisu.error import PropertiesOptionError, RequirementError, LeadershipError from tiramisu.error import PropertiesOptionError, RequirementError, LeadershipError
except ModuleNotFoundError: except (ModuleNotFoundError, ImportError):
Config = None Config = None
from tiramisu_api.error import PropertiesOptionError from tiramisu_api.error import PropertiesOptionError
RequirementError = PropertiesOptionError RequirementError = PropertiesOptionError
@ -164,10 +164,12 @@ class _BuildKwargs:
is_short_name = self.cmdlineparser._is_short_name(name, 'longargument' in self.properties) is_short_name = self.cmdlineparser._is_short_name(name, 'longargument' in self.properties)
if self.force_no: if self.force_no:
ga_name = self.gen_argument_name(name, is_short_name) ga_name = self.gen_argument_name(name, is_short_name)
self.cmdlineparser.namespace.list_force_no[ga_name] = option.path() ga_path = self.gen_argument_name(option.path(), is_short_name)
self.cmdlineparser.namespace.list_force_no[ga_path] = option.path()
elif self.force_del: elif self.force_del:
ga_name = self.gen_argument_name(name, is_short_name) ga_name = self.gen_argument_name(name, is_short_name)
self.cmdlineparser.namespace.list_force_del[ga_name] = option.path() ga_path = self.gen_argument_name(option.path(), is_short_name)
self.cmdlineparser.namespace.list_force_del[ga_path] = option.path()
else: else:
ga_name = name ga_name = name
self.kwargs['dest'] = self.gen_argument_name(option.path(), False) self.kwargs['dest'] = self.gen_argument_name(option.path(), False)