works with test/auto tests

This commit is contained in:
2019-07-06 07:18:32 +02:00
parent fb1286e50e
commit d3eef77c03
64 changed files with 1293 additions and 152 deletions

View File

@ -1091,7 +1091,7 @@ msgstr "context n'est pas supporté maintenant pour {}"
#: tiramisu/todict.py:82 tiramisu/todict.py:91
msgid "option {} only works when remotable is not \"none\""
msgstr "l'option {} ne fonctionne que si remotable is \"none\""
msgstr "l'option {} ne fonctionne que si remotable n'est pas \"none\""
#: tiramisu/todict.py:706 tiramisu/todict.py:839
msgid "unknown form {}"

View File

@ -118,10 +118,12 @@ class Consistencies(object):
def process(self, form):
for path in self.not_equal:
if self.tiramisu_web.is_remote(path, form):
continue
if path not in form:
form[path] = {}
for warnings_only in self.not_equal[path]:
options = self.not_equal[path][warnings_only]
if path not in form:
form[path] = {}
if 'not_equal' not in form[path]:
form[path]['not_equal'] = []
obj = {'options': options}
@ -137,6 +139,17 @@ class Requires(object):
self.tiramisu_web = tiramisu_web
self.action_hide = self.tiramisu_web.config._config_bag.properties
def set_master_remote(self, childapi, path, form):
if childapi.option.isoptiondescription():
isfollower = False
else:
isfollower = childapi.option.isfollower()
if isfollower:
parent_path = path.rsplit('.', 1)[0]
parent = self.tiramisu_web.config.unrestraint.option(parent_path)
leader = next(parent.list())
self.tiramisu_web.set_remotable(leader.option.path(), form, leader)
def manage_requires(self,
childapi,
path,
@ -144,15 +157,6 @@ class Requires(object):
current_action):
for requires in childapi.option.requires():
len_to_long = len(requires) > 1
if childapi.option.isoptiondescription():
isfollower = False
else:
isfollower = childapi.option.isfollower()
if isfollower:
parent_path = path.rsplit('.', 1)[0]
parent = self.tiramisu_web.config.unrestraint.option(parent_path)
leader = next(parent.list())
self.tiramisu_web.set_remotable(leader.option.path(), form, leader)
for require in requires:
options, action, inverse, transitive, same_action, operator = require
if not len_to_long:
@ -162,53 +166,51 @@ class Requires(object):
for option_param in chain(option[1].args, option[1].kwargs.values()):
if isinstance(option_param, ParamOption):
self.tiramisu_web.set_remotable(option_param.option.impl_getpath(), form)
self.set_master_remote(childapi, path, form)
elif len_to_long:
self.tiramisu_web.set_remotable(option.impl_getpath(), form)
self.set_master_remote(childapi, path, form)
else:
option_path = option.impl_getpath()
if action in self.action_hide:
if childapi.option.isoptiondescription() or isfollower:
self.tiramisu_web.set_remotable(option_path, form)
continue
require_option = self.tiramisu_web.config.unrestraint.option(option_path)
if transitive is False or same_action is False or operator == 'and':
# transitive to "False" not supported yet for a requirement
# same_action to "False" not supported yet for a requirement
# operator "and" not supported yet for a requirement
self.tiramisu_web.set_remotable(option_path, form, require_option)
self.set_master_remote(childapi, path, form)
if require_option.option.requires():
for reqs in require_option.option.requires():
for req in reqs:
for subopt, subexp in req[0]:
if not isinstance(subopt, tuple):
self.tiramisu_web.set_remotable(subopt.impl_getpath(), form)
if isinstance(option, ChoiceOption):
require_option = self.tiramisu_web.config.unrestraint.option(option_path)
if require_option.value.callbacks():
self.tiramisu_web.set_remotable(option_path, form, require_option)
continue
else:
values = self.tiramisu_web.get_enum(require_option,
require_option.option.ismulti(),
option_path,
require_option.option.properties())
for value in values:
if value not in expected:
self.requires.setdefault(path,
{'expected': {}}
)['expected'].setdefault(value,
{}).setdefault(inv_act,
[]).append(option_path)
if current_action is None:
current_action = action
elif current_action != action:
self.tiramisu_web.set_remotable(option_path, form)
self.set_master_remote(childapi, path, form)
if inverse:
act = 'show'
inv_act = 'hide'
else:
act = 'hide'
inv_act = 'show'
if isinstance(option, ChoiceOption):
require_option = self.tiramisu_web.config.unrestraint.option(option_path)
values = self.tiramisu_web.get_enum(require_option,
require_option.option.ismulti(),
option_path,
require_option.option.properties())
for value in values:
if value not in expected:
self.requires.setdefault(path,
{'expected': {}}
)['expected'].setdefault(value,
{}).setdefault(inv_act,
[]).append(option_path)
if current_action is None:
current_action = action
elif current_action != action:
self.tiramisu_web.set_remotable(option_path, form)
self.set_master_remote(childapi, path, form)
for exp in expected:
self.requires.setdefault(path,
{'expected': {}}
@ -218,6 +220,7 @@ class Requires(object):
self.requires[path].setdefault('default', {}).setdefault(inv_act, []).append(option_path)
else:
self.tiramisu_web.set_remotable(option_path, form)
self.set_master_remote(childapi, path, form)
def add(self, path, childapi, form):
#collect id of all options
@ -232,12 +235,6 @@ class Requires(object):
form,
current_action)
def is_remote(self, path, form):
if self.tiramisu_web.remotable == 'all':
return True
else:
return form.get(path) and form[path].get('remote', False)
def process(self, form):
dependencies = {}
for path, values in self.requires.items():
@ -245,7 +242,7 @@ class Requires(object):
for option in values['default'].get('show', []):
if path == option:
self.tiramisu_web.set_remotable(path, form)
if not self.is_remote(option, form):
if not self.tiramisu_web.is_remote(option, form):
dependencies.setdefault(option,
{'default': {}, 'expected': {}}
)['default'].setdefault('show', [])
@ -254,7 +251,7 @@ class Requires(object):
for option in values['default'].get('hide', []):
if path == option:
self.tiramisu_web.set_remotable(path, form)
if not self.is_remote(option, form):
if not self.tiramisu_web.is_remote(option, form):
dependencies.setdefault(option,
{'default': {}, 'expected': {}}
)['default'].setdefault('hide', [])
@ -266,7 +263,7 @@ class Requires(object):
for option in actions.get('show', []):
if path == option:
self.tiramisu_web.set_remotable(path, form)
if not self.is_remote(option, form):
if not self.tiramisu_web.is_remote(option, form):
dependencies.setdefault(option,
{'expected': {}}
)['expected'].setdefault(expected,
@ -276,7 +273,7 @@ class Requires(object):
for option in actions.get('hide', []):
if path == option:
self.tiramisu_web.set_remotable(path, form)
if not self.is_remote(option, form):
if not self.tiramisu_web.is_remote(option, form):
dependencies.setdefault(option,
{'expected': {}}
)['expected'].setdefault(expected,
@ -336,6 +333,12 @@ class TiramisuDict:
path = root + '.' + childname
yield path, childapi
def is_remote(self, path, form):
if self.remotable == 'all':
return True
else:
return path in form and form[path].get('remote', False) == True
def set_remotable(self, path, form, childapi=None):
if self.remotable == 'none':
raise ValueError(_('option {} only works when remotable is not "none"').format(path))
@ -500,9 +503,6 @@ class TiramisuDict:
if childapi_option.issymlinkoption():
schema[path]['opt_path'] = childapi_option.get().impl_getopt().impl_getpath()
else:
if value is not None:
schema[path]['value'] = value
if defaultmulti is not None:
schema[path]['defaultmulti'] = defaultmulti
@ -526,6 +526,9 @@ class TiramisuDict:
is_multi,
path,
props_no_requires)
if value is not None and not self.is_remote(path, form):
schema[path]['value'] = value
def get_enum(self,
childapi,
@ -630,20 +633,24 @@ class TiramisuDict:
if not isfollower and ismulti:
if 'empty' in properties:
obj['required'] = True
properties.remove('empty')
if 'mandatory' in properties:
obj['needs_len'] = True
properties.remove('mandatory')
elif 'mandatory' in properties:
obj['required'] = True
properties.remove('mandatory')
if 'frozen' in properties:
obj['readOnly'] = True
#if 'hidden' in properties:
# obj['hidden'] = True
#if 'disabled' in properties:
# obj['hidden'] = True
properties.remove('frozen')
if 'hidden' in properties:
properties.remove('hidden')
if 'disabled' in properties:
properties.remove('disabled')
if properties:
lprops = list(properties)
lprops.sort()
obj['props'] = lprops
obj['properties'] = lprops
return obj
def gen_model(self,