restore tests

This commit is contained in:
Emmanuel Garette 2020-12-24 17:37:14 +01:00
parent d395f4a17b
commit f9885a023c
32 changed files with 250 additions and 34 deletions

View File

@ -396,7 +396,7 @@ class ConstrainteAnnotator:
# build choice
variable.choice = []
if isinstance(values, str):
choice = self.objectspace.choice()
choice = self.objectspace.choice(variable.xmlfiles)
choice.type = 'calculation'
choice.name = values
variable.choice.append(choice)

View File

@ -480,10 +480,10 @@ class Family(Common):
if 'properties' in self.attrib:
self.attrib['properties'] = "'" + "', '".join(sorted(list(self.attrib['properties']))) + "'"
if hasattr(self.elt, 'property'):
#self.attrib['properties'] = ''
for child in self.elt.property:
self.populate_properties(child)
if not self.attrib['properties']:
# remove empty property
del self.attrib['properties']
def get_object_name(self):

View File

@ -1,11 +0,0 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])

View File

@ -1,11 +0,0 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])

View File

@ -0,0 +1,34 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services>
<service name="test">
<file name="/tmp/file" filelist="afilllist"/>
</service>
</services>
<variables>
<family name="general">
<variable name="condition" type="string" description="No change">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif" type="oui/non" description="No change" hidden="True">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif2" type="oui/non" description="No change" hidden="True">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<check name="valid_enum" target="condition">
<param>non</param>
<param>statique</param>
</check>
<condition name="disabled_if_not_in" source="condition">
<param>statique</param>
<target type="filelist">afilllist</target>
</condition>
</constraints>
</rougail>

View File

@ -0,0 +1 @@
{"rougail.general.condition": "non", "rougail.general.mode_conteneur_actif": "non", "rougail.general.mode_conteneur_actif2": "non", "services.test.files.file.group": "root", "services.test.files.file.mode": "0644", "services.test.files.file.name": "/tmp/file", "services.test.files.file.owner": "root", "services.test.files.file.source": "file", "services.test.files.file.templating": true}

View File

@ -8,4 +8,21 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='condition', doc='No change', multi=False, default='non', values=('non', 'statique'))
option_4 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_5 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif2', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4, option_5])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_10 = StrOption(name='group', doc='group', multi=False, default='root')
option_11 = StrOption(name='mode', doc='mode', multi=False, default='0644')
option_12 = StrOption(name='name', doc='name', multi=False, default='/tmp/file')
option_13 = StrOption(name='owner', doc='owner', multi=False, default='root')
option_14 = StrOption(name='source', doc='source', multi=False, default='file')
option_15 = BoolOption(name='templating', doc='templating', multi=False, default=True)
option_16 = BoolOption(properties=frozenset({Calculation(calc_value, Params(ParamValue('disabled'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('statique'), 'reverse_condition': ParamValue(True)}))}), name='activate', doc='activate', multi=False, default=True)
option_9 = OptionDescription(name='file', doc='file', children=[option_10, option_11, option_12, option_13, option_14, option_15, option_16])
option_8 = OptionDescription(name='files', doc='files', children=[option_9])
option_7 = OptionDescription(name='test', doc='test', children=[option_8])
option_7.impl_set_information("manage", True)
option_6 = OptionDescription(name='services', doc='services', properties=frozenset({'hidden'}), children=[option_7])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_6])

View File

@ -0,0 +1,22 @@
<?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>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "a", "rougail.general.var": ["a", "b", "c"]}

View File

@ -0,0 +1,15 @@
from importlib.machinery import SourceFileLoader
func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module()
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_4 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='var', doc='New variable', multi=True, default=['a', 'b', 'c'], default_multi='c')
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='a', values=Calculation(func.calc_value, Params((ParamOption(option_4)))))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3, option_4])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail>
<variables>
<family name='general'>
<variable name='varname' type='string' description="No change" multi="True">
<value>val1</value>
<value>val2</value>
</variable>
</family>
<family name='dyn' dynamic="varname">
<variable name='vardyn' type='string' description="No change">
<value>val</value>
</variable>
</family>
<family name='new'>
<variable name='newvar' type='string' description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="newvar">
<param type="variable">vardynval1</param>
</fill>
</constraints>
</rougail>

View File

@ -0,0 +1 @@
{"rougail.general.varname": ["val1", "val2"], "rougail.dynval1.vardynval1": "val", "rougail.dynval2.vardynval2": "val", "rougail.new.newvar": "val"}

View File

@ -8,4 +8,11 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='varname', doc='No change', multi=True, default=['val1', 'val2'], default_multi='val2')
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_5 = StrOption(properties=frozenset({'mandatory', 'normal'}), name='vardyn', doc='No change', multi=False, default='val')
option_4 = ConvertDynOptionDescription(name='dyn', doc='dyn', suffixes=Calculation(func.calc_value, Params((ParamOption(option_3)))), properties=frozenset({'normal'}), children=[option_5])
option_7 = StrOption(properties=frozenset({'normal'}), name='newvar', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamDynOption(option_5, 'val1', option_4, notraisepropertyerror=False, todict=False)), kwargs={})))
option_6 = OptionDescription(name='new', doc='new', properties=frozenset({'normal'}), children=[option_7])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4, option_6])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="mode_conteneur_actif">
<param>value</param>
</fill>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "value"}

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamValue("value")), kwargs={})))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="No change"/>
</family>
</variables>
<constraints>
<fill name="calc_val" target="mode_conteneur_actif">
<param>value</param>
</fill>
</constraints>
</rougail>

View File

@ -1 +1 @@
{}
{"rougail.general.mode_conteneur_actif": "value"}

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = StrOption(properties=frozenset({'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamValue("value")), kwargs={})))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,33 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<family name="general2" hidden="True">
<variable name="mode_conteneur_actif2" type="oui/non" description="No change">
<value>non</value>
</variable>
<variable name="mode_conteneur_actif3" type="string" description="No change"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif3">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
<condition name="disabled_if_in" source="mode_conteneur_actif3">
<param>d</param>
<target type="variable">mode_conteneur_actif</target>
</condition>
<condition name="disabled_if_not_in" source="mode_conteneur_actif3">
<param>d</param>
<target type="variable">mode_conteneur_actif2</target>
</condition>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general2.mode_conteneur_actif3": "a"}

View File

@ -8,4 +8,10 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_5 = ChoiceOption(properties=frozenset({'disabled', 'mandatory', 'normal'}), name='mode_conteneur_actif2', doc='No change', multi=False, default='non', values=('oui', 'non'))
option_6 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='mode_conteneur_actif3', doc='No change', multi=False, default='a', values=('a', 'b', 'c'))
option_4 = OptionDescription(name='general2', doc='general2', properties=frozenset({'hidden', 'normal'}), children=[option_5, option_6])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2, option_4])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="string" description="Redefine description" hidden="True"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param>a</param>
<param>b</param>
<param>c</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" redefine="True" remove_check="True"/>
</family>
</variables>
<constraints>
<check name="valid_enum" target="mode_conteneur_actif">
<param>a</param>
<param>b</param>
</check>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"rougail.general.mode_conteneur_actif": "a"}

View File

@ -8,4 +8,7 @@ try:
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[])
option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='Redefine description', multi=False, default='a', values=('a', 'b'))
option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'normal'}), children=[option_3])
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])

View File

@ -5,7 +5,7 @@ from pytest import fixture, raises
from os import listdir
from json import load
from rougail import Rougail, annotator
from rougail import Rougail
from rougail.error import DictConsistencyError
from rougail.config import Config
@ -28,9 +28,10 @@ excludes = set([])
#excludes = set(['01base_file_utfchar'])
test_ok -= excludes
test_raise -= excludes
#test_ok = ['40condition_base_add']
#test_ok = ['10valid_enum_eosfunc']
#test_ok = []
#test_raise = ['80redefine_double_error']
#test_raise = []
ORI_DIR = getcwd()
@ -70,6 +71,8 @@ def launch_flattener(test_dir, test_ok=False):
Config['patch_dir'] = join(test_dir, 'patches')
eolobj.space_visitor(eosfunc)
tiramisu_objects = eolobj.save()
if 'children=[]' in tiramisu_objects.split('\n')[-2]:
raise Exception('empty tiramisu object?')
tiramisu_dir = join(test_dir, 'tiramisu')
if isdir(tiramisu_dir):
tiramisu_file = join(tiramisu_dir, 'base.py')

View File

@ -50,7 +50,7 @@ async def launch_flattener(test_dir):
if config_dict:
if not isdir(makedict_dir):
mkdir(makedict_dir)
if debug:
if not isfile(makedict_file) or debug:
with open(makedict_file, 'w') as fh:
dump(config_dict, fh)
fh.write('\n')