test suffix

This commit is contained in:
2020-12-24 18:26:15 +01:00
parent 942b3f718c
commit 6a771913e0
10 changed files with 87 additions and 5 deletions

View File

@ -504,7 +504,8 @@ class ConstrainteAnnotator:
targets.append(fill.target)
#
if fill.name not in self.functions:
raise DictConsistencyError(_('cannot find fill function {}').format(fill.name), 25)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'cannot find fill function {fill.name} in {xmlfiles}'), 25)
namespace = fill.namespace
# let's replace the target by the path
@ -513,7 +514,8 @@ class ConstrainteAnnotator:
with_suffix=True,
)
if suffix is not None:
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}"'), 26)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'Cannot add fill function to "{fill.target}" only with the suffix "{suffix}" in {xmlfiles}'), 26)
variable = self.objectspace.paths.get_variable_obj(fill.target)
value = self.objectspace.value(variable.xmlfiles)
value.type = 'calculation'
@ -522,9 +524,15 @@ class ConstrainteAnnotator:
param_to_delete = []
for fill_idx, param in enumerate(fill.param):
if param.type not in ['suffix', 'string'] and not hasattr(param, 'text'):
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target}"), 27)
if param.type == 'suffix' and hasattr(param, 'text'):
raise DictConsistencyError(_(f"All '{param.type}' variables must not have a value in order to calculate {fill.target}"), 28)
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f"All '{param.type}' variables must have a value in order to calculate {fill.target} in {xmlfiles}"), 27)
if param.type == 'suffix':
if hasattr(param, 'text'):
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f"All '{param.type}' variables must not have a value in order to calculate {fill.target} in {xmlfiles}"), 28)
if not self.objectspace.paths.variable_is_dynamic(fill.target):
xmlfiles = self.objectspace.display_xmlfiles(fill.xmlfiles)
raise DictConsistencyError(_(f'Cannot set suffix target to the none dynamic variable "{fill.target}" in {xmlfiles}'), 53)
if param.type == 'string':
if not hasattr(param, 'text'):
param.text = None

View File

@ -174,6 +174,11 @@ class Path:
return True
return name in self.variables
def variable_is_dynamic(self,
name: str,
) -> bool:
return self._get_variable(name)['is_dynamic']
def _get_variable(self,
name: str,
with_suffix: bool=False,