add valid_enum tests
This commit is contained in:
parent
2d0ccc6896
commit
71b9b70755
|
@ -126,7 +126,8 @@ class ConstrainteAnnotator:
|
||||||
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
||||||
raise DictConsistencyError(_(f'valid_enum define in {xmlfiles} but already set in {old_xmlfiles} for "{check.target}", did you forget remove_check?'), 3)
|
raise DictConsistencyError(_(f'valid_enum define in {xmlfiles} but already set in {old_xmlfiles} for "{check.target}", did you forget remove_check?'), 3)
|
||||||
if not hasattr(check, 'param'):
|
if not hasattr(check, 'param'):
|
||||||
raise DictConsistencyError(_(f'param is mandatory for a valid_enum of variable {check.target}'), 4)
|
xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles)
|
||||||
|
raise DictConsistencyError(_(f'param is mandatory for a valid_enum of variable "{check.target}" in {xmlfiles}'), 4)
|
||||||
variable = self.objectspace.paths.get_variable_obj(check.target)
|
variable = self.objectspace.paths.get_variable_obj(check.target)
|
||||||
values = self.load_params_in_valid_enum(check.param,
|
values = self.load_params_in_valid_enum(check.param,
|
||||||
variable.name,
|
variable.name,
|
||||||
|
@ -153,18 +154,22 @@ class ConstrainteAnnotator:
|
||||||
for param in params:
|
for param in params:
|
||||||
if param.type == 'variable':
|
if param.type == 'variable':
|
||||||
if has_variable is not None:
|
if has_variable is not None:
|
||||||
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable {variable_name}'), 5)
|
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||||
|
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 5)
|
||||||
has_variable = True
|
has_variable = True
|
||||||
variable = self.objectspace.paths.get_variable_obj(param.text)
|
variable = self.objectspace.paths.get_variable_obj(param.text)
|
||||||
if not variable.multi:
|
if not variable.multi:
|
||||||
raise DictConsistencyError(_(f'only multi "variable" parameter is allowed for valid_enum of variable {variable_name}'), 6)
|
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||||
|
raise DictConsistencyError(_(f'only multi "variable" parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 6)
|
||||||
values = param.text
|
values = param.text
|
||||||
else:
|
else:
|
||||||
if has_variable:
|
if has_variable:
|
||||||
raise DictConsistencyError(_(f'only one "variable" parameter is allowed for valid_enum of variable {variable_name}'), 7)
|
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||||
|
raise DictConsistencyError(_(f'only one parameter is allowed for valid_enum of variable "{variable_name}" in {xmlfiles}'), 7)
|
||||||
if not hasattr(param, 'text'):
|
if not hasattr(param, 'text'):
|
||||||
if param.type == 'number':
|
if param.type == 'number':
|
||||||
raise DictConsistencyError(_(f'value is mandatory for valid_enum of variable {variable_name}'), 8)
|
xmlfiles = self.objectspace.display_xmlfiles(param.xmlfiles)
|
||||||
|
raise DictConsistencyError(_(f'param type is number, so value is mandatory for valid_enum of variable "{variable_name}" in {xmlfiles}'), 8)
|
||||||
values.append(None)
|
values.append(None)
|
||||||
else:
|
else:
|
||||||
values.append(param.text)
|
values.append(param.text)
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail>
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" type="string" description="No change">
|
||||||
|
<value>a</value>
|
||||||
|
</variable>
|
||||||
|
<variable name="var" type="string" description="New variable" multi="True">
|
||||||
|
<value>a</value>
|
||||||
|
<value>b</value>
|
||||||
|
<value>c</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
<constraints>
|
||||||
|
<check name="valid_enum" target="mode_conteneur_actif">
|
||||||
|
<param type="variable">var</param>
|
||||||
|
<param>d</param>
|
||||||
|
</check>
|
||||||
|
</constraints>
|
||||||
|
</rougail>
|
||||||
|
<!-- vim: ts=4 sw=4 expandtab
|
||||||
|
-->
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail>
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" type="string" description="No change">
|
||||||
|
<value>a</value>
|
||||||
|
</variable>
|
||||||
|
<variable name="var" type="string" description="New variable" multi="True">
|
||||||
|
<value>a</value>
|
||||||
|
<value>b</value>
|
||||||
|
<value>c</value>
|
||||||
|
</variable>
|
||||||
|
<variable name="var2" type="string" description="New variable" multi="True">
|
||||||
|
<value>a</value>
|
||||||
|
<value>b</value>
|
||||||
|
<value>c</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
<constraints>
|
||||||
|
<check name="valid_enum" target="mode_conteneur_actif">
|
||||||
|
<param type="variable">var</param>
|
||||||
|
<param type="variable">var2</param>
|
||||||
|
</check>
|
||||||
|
</constraints>
|
||||||
|
</rougail>
|
||||||
|
<!-- vim: ts=4 sw=4 expandtab
|
||||||
|
-->
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail>
|
||||||
|
<variables>
|
||||||
|
<family name="general" mode="expert">
|
||||||
|
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
||||||
|
<value>non</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
<family name="enumfam" mode="expert">
|
||||||
|
<variable name="enumvar" type="string" description="multi" help="bla bla bla">
|
||||||
|
<value>c</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
<separators/>
|
||||||
|
</variables>
|
||||||
|
|
||||||
|
<constraints>
|
||||||
|
<check name="valid_enum" target="enumvar"/>
|
||||||
|
</constraints>
|
||||||
|
</rougail>
|
||||||
|
<!-- vim: ts=4 sw=4 expandtab
|
||||||
|
-->
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail>
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" type="string" description="No change">
|
||||||
|
<value>a</value>
|
||||||
|
</variable>
|
||||||
|
<variable name="var" type="string" description="New variable">
|
||||||
|
<value>a</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
<constraints>
|
||||||
|
<check name="valid_enum" target="mode_conteneur_actif">
|
||||||
|
<param type="variable">var</param>
|
||||||
|
</check>
|
||||||
|
</constraints>
|
||||||
|
</rougail>
|
||||||
|
<!-- vim: ts=4 sw=4 expandtab
|
||||||
|
-->
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail>
|
||||||
|
<variables>
|
||||||
|
<family name="general" mode="expert">
|
||||||
|
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
||||||
|
<value>non</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
<family name="enumfam" mode="expert">
|
||||||
|
<variable name="enumvar" type="number" description="enumvar" help="bla bla bla"/>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
|
||||||
|
<constraints>
|
||||||
|
<check name="valid_enum" target="enumvar">
|
||||||
|
<param type="number"/>
|
||||||
|
</check>
|
||||||
|
</constraints>
|
||||||
|
|
||||||
|
</rougail>
|
||||||
|
<!-- vim: ts=4 sw=4 expandtab
|
||||||
|
-->
|
Loading…
Reference in New Issue