better slate tests

This commit is contained in:
2017-07-09 21:28:22 +02:00
parent c8bc3093c7
commit 01c37c3713
4 changed files with 89 additions and 25 deletions

View File

@ -104,10 +104,10 @@ def validate_callback(callback, callback_params, type_, callbackoption):
cur_opt = option
if cur_opt != callbackoption:
if not getattr(cur_opt, '_dependencies', None):
options = []
options = set()
else:
options = list(cur_opt._dependencies)
options.append(callbackoption)
options = set(cur_opt._dependencies)
options.add(callbackoption)
cur_opt._dependencies = tuple(options)
#____________________________________________________________
#
@ -274,11 +274,16 @@ class BaseOption(Base):
self._dependencies = []
for dependency in self._state_dependencies:
option = descr.impl_get_opt_by_path(dependency)
if option.impl_is_optiondescription() and \
option.impl_get_group_type() == groups.master:
master_path = dependency + '.' + dependency.split('.')[-1]
option = descr.impl_get_opt_by_path(master_path).impl_get_master_slaves()
if option.impl_is_optiondescription():
# test if _group_type is already loaded
group_type = getattr(option, '_group_type', undefined)
if group_type is undefined:
group_type = getattr(groups, option._state_group_type)
if group_type == groups.master:
master_path = dependency + '.' + dependency.split('.')[-1]
option = descr.impl_get_opt_by_path(master_path).impl_get_master_slaves()
self._dependencies.append(option)
self._dependencies = tuple(self._dependencies)
del(self._state_dependencies)
else:
self._state_dependencies = []
@ -995,10 +1000,10 @@ def validate_requires_arg(new_option, multi, requires, name):
"""
def set_dependency(option):
if not getattr(option, '_dependencies', None):
options = []
options = set()
else:
options = list(option._dependencies)
options.append(new_option)
options = set(option._dependencies)
options.add(new_option)
option._dependencies = tuple(options)
def get_option(require):

View File

@ -127,10 +127,10 @@ class OptionDescription(BaseOption, StorageOptionDescription):
else:
if option.impl_is_master_slaves('master'):
if not getattr(option, '_dependencies', None):
options = []
options = set()
else:
options = list(option._dependencies)
options.append(option.impl_get_master_slaves())
options = set(option._dependencies)
options.add(option.impl_get_master_slaves())
option._dependencies = tuple(options)
option._set_readonly(True)
is_multi = option.impl_is_multi()