diff --git a/src/rougail_tests/utils.py b/src/rougail_tests/utils.py index 3cb9f9f..c28c378 100644 --- a/src/rougail_tests/utils.py +++ b/src/rougail_tests/utils.py @@ -8,8 +8,10 @@ from .custom import CustomOption root_test_dir = Path(__file__).parent.parent.parent / 'structures' -def get_structures_list(excludes): - return [test for test in sorted(root_test_dir.iterdir()) if test.name not in excludes] +def get_structures_list(excludes, done_root_dir=None): + return [test for test in sorted(root_test_dir.iterdir()) if test.name not in excludes and (not done_root_dir or not (done_root_dir / (test.name + ".DONE")).is_file())] + # FIXME +# return [test for test in sorted(root_test_dir.iterdir()) if test.name not in excludes and (not done_root_dir or (done_root_dir / (test.name + ".DONE")).is_file())] def get_funcs(): @@ -110,6 +112,7 @@ def get_value(variable, index, excludes, config, use_unrestraint, follower_with_ if 'force_store_value' in variable.property.get(): return variable.value.get() tests = variable.information.get('test', None) + l_tests = None if variable.path(uncalculated=True) in excludes and variable.value.get(uncalculated=True): tests = variable.value.get() elif tests: @@ -120,7 +123,9 @@ def get_value(variable, index, excludes, config, use_unrestraint, follower_with_ elif variable.type() == 'float': tests = [1.1, 2.2, 3.3] elif variable.type() == 'port': - tests = ['80', '443'] + # authorize port as an integer but it's a string + tests = [80, '443'] + l_tests = ["80", "443"] elif variable.type() == 'boolean': tests = [True] elif variable.type() == 'domain name': @@ -152,8 +157,11 @@ def get_value(variable, index, excludes, config, use_unrestraint, follower_with_ tests = [password] else: tests = ['string1', 'string2', 'string3'] + if l_tests is None: + l_tests = tests if not variable.ismulti(): tests = tests[0] + l_tests = l_tests[0] elif variable.isleader() and variable.owner.get() == owners.default: len_leader = len(variable.value.get()) if len_leader: @@ -162,11 +170,13 @@ def get_value(variable, index, excludes, config, use_unrestraint, follower_with_ elif index is not None and variable.isfollower() and variable.issubmulti() is False: if len(tests) > index: tests = tests[index] + l_tests = l_tests[index] else: tests = tests[0] + l_tests = l_tests[0] # if not use_unrestraint: # config.property.read_write() - variable.value.set(tests) + variable.value.set(l_tests) if variable.index() is None: variable.information.set('loaded_from', 'loaded from rougail-test') else: @@ -251,3 +261,43 @@ def config_to_dict(parent, key_is_option=False): yield option, value else: yield option.path(), value + + +def fake_errors_for_user_data(): + return [{'source': 'fake user data', + 'errors': [], + 'warnings': [], + 'values': {'family1.integer': 'not_an_integer', 'family1.string': 3}, + 'options': {} + } + ] + + +def fake_errors_for_user_data2(): + return [{'source': 'fake user data', + 'errors': [], + 'warnings': [], + 'values': {'family1.family2.integer': 'not_an_integer', 'family1.string': 3}, + 'options': {} + } + ] + + +def fake_for_user_data(variable_name="family1.variable"): + return [{'source': 'fake user data', + 'errors': [], + 'warnings': [], + 'values': {variable_name: 'value'}, + 'options': {} + } + ] + + +def fake_dynamic_for_user_data(): + return [{'source': 'fake user data', + 'errors': [], + 'warnings': [], + 'values': {'dynval1.val': 'a value 1', 'dynval2.val': 'a value 2', 'dynVal3.val': 'a value 3'}, + 'options': {} + } + ] diff --git a/structures/00_2default_calculated_multi/rougail/00-base.yml b/structures/00_2default_calculated_multi/rougail/00-base.yml index d2d4efb..c995000 100644 --- a/structures/00_2default_calculated_multi/rougail/00-base.yml +++ b/structures/00_2default_calculated_multi/rougail/00-base.yml @@ -12,4 +12,4 @@ var2: {% for val in _.var1 %} {{ val }} {% endfor %} - description: the value of _.var1 + description: the value of "_.var1" diff --git a/structures/00_6ip/rougail/00-base.yml b/structures/00_6ip/rougail/00-base.yml index 6333e6d..f3f8125 100644 --- a/structures/00_6ip/rougail/00-base.yml +++ b/structures/00_6ip/rougail/00-base.yml @@ -14,7 +14,7 @@ var2: cidr: true default: 1.1.1.1/24 examples: - - 192.168.0.128/25 + - 192.168.0.129/25 var3: description: an IP in CIDR format with obsolete CIDR type diff --git a/structures/00_6secret_param/rougail/00-base.yml b/structures/00_6secret_param/rougail/00-base.yml index c2f0783..148e324 100644 --- a/structures/00_6secret_param/rougail/00-base.yml +++ b/structures/00_6secret_param/rougail/00-base.yml @@ -5,6 +5,8 @@ secret1: type: secret params: min_len: 10 + examples: + - ALongS4cr4t secret2: description: the second variable type: secret diff --git a/structures/00_8calculation_information/rougail/00-base.yml b/structures/00_8calculation_information/rougail/00-base.yml index 58a188b..159b05d 100644 --- a/structures/00_8calculation_information/rougail/00-base.yml +++ b/structures/00_8calculation_information/rougail/00-base.yml @@ -4,7 +4,7 @@ variable: description: a variable default: jinja: | - {{test_information }} + {{ test_information }} params: test_information: type: information diff --git a/structures/00_9default_calculation_information/informations.json b/structures/00_9default_calculation_information/informations.json new file mode 100644 index 0000000..388b250 --- /dev/null +++ b/structures/00_9default_calculation_information/informations.json @@ -0,0 +1 @@ +{"rougail.var": "value"} diff --git a/structures/00_9default_calculation_information_other_variable/informations.json b/structures/00_9default_calculation_information_other_variable/informations.json new file mode 100644 index 0000000..8922f27 --- /dev/null +++ b/structures/00_9default_calculation_information_other_variable/informations.json @@ -0,0 +1 @@ +{"rougail.var1": "value"} diff --git a/structures/00_9default_information_other_variable/informations.json b/structures/00_9default_information_other_variable/informations.json new file mode 100644 index 0000000..8922f27 --- /dev/null +++ b/structures/00_9default_information_other_variable/informations.json @@ -0,0 +1 @@ +{"rougail.var1": "value"} diff --git a/structures/01_6string_multi_length/rougail/00-base.yml b/structures/01_6string_multi_length/rougail/00-base.yml new file mode 100644 index 0000000..58c6d8c --- /dev/null +++ b/structures/01_6string_multi_length/rougail/00-base.yml @@ -0,0 +1,21 @@ +%YAML 1.2 +--- +version: 1.1 + +var1: + description: the variable + default: + - val1 + - val2 + - val3 + params: + multi_length: 3 + +var2: + description: the variable + default: + - val4 + - val5 + params: + multi_min_length: 1 + multi_max_length: 4 diff --git a/structures/04_1jinja_and_hidden/rougail/00-base.yml b/structures/04_1jinja_and_hidden/rougail/00-base.yml new file mode 100644 index 0000000..c1f7005 --- /dev/null +++ b/structures/04_1jinja_and_hidden/rougail/00-base.yml @@ -0,0 +1,18 @@ +%YAML 1.2 +--- +version: 1.1 + +var1: + description: A first variable + type: boolean + default: + jinja: |- + true + description: A description + hidden: true + +var2: + description: A second variable + disabled: + variable: _.var1 +... diff --git a/structures/04_5disabled_calculation_variable_transitive/rougail/00-base.yml b/structures/04_5disabled_calculation_variable_transitive/rougail/00-base.yml new file mode 100644 index 0000000..9ed90c1 --- /dev/null +++ b/structures/04_5disabled_calculation_variable_transitive/rougail/00-base.yml @@ -0,0 +1,19 @@ +%YAML 1.2 +--- +version: 1.1 + +condition: + description: a condition + default: true + +variable1: + description: a variable + disabled: + variable: _.condition + +variable2: + description: a second variable + disabled: + variable: _.variable1 + propertyerror: transitive +... diff --git a/structures/04_5disabled_calculation_variable_transitive_2/rougail/00-base.yml b/structures/04_5disabled_calculation_variable_transitive_2/rougail/00-base.yml new file mode 100644 index 0000000..4becb50 --- /dev/null +++ b/structures/04_5disabled_calculation_variable_transitive_2/rougail/00-base.yml @@ -0,0 +1,11 @@ +--- +version: '1.1' +condition: + description: a condition + default: true + disabled: true +variable: + description: a variable + disabled: + variable: _.condition + propertyerror: transitive diff --git a/structures/04_5disabled_calculation_variable_transitive_3/rougail/00-base.yml b/structures/04_5disabled_calculation_variable_transitive_3/rougail/00-base.yml new file mode 100644 index 0000000..022ef6f --- /dev/null +++ b/structures/04_5disabled_calculation_variable_transitive_3/rougail/00-base.yml @@ -0,0 +1,21 @@ +%YAML 1.2 +--- +version: 1.1 + +condition: + description: a condition + default: false + +variable1: + description: a variable + default: disabled + disabled: + variable: _.condition + +variable2: + description: a second variable + disabled: + variable: _.variable1 + propertyerror: transitive + when: disabled +... diff --git a/structures/04_5disabled_calculation_variable_transitive_4/rougail/00-base.yml b/structures/04_5disabled_calculation_variable_transitive_4/rougail/00-base.yml new file mode 100644 index 0000000..6811edf --- /dev/null +++ b/structures/04_5disabled_calculation_variable_transitive_4/rougail/00-base.yml @@ -0,0 +1,21 @@ +%YAML 1.2 +--- +version: 1.1 + +condition: + description: a condition + default: true + +variable1: + description: a variable + default: not_disabled + disabled: + variable: _.condition + +variable2: + description: a second variable + disabled: + variable: _.variable1 + propertyerror: transitive + when: disabled +... diff --git a/structures/20_7help_family/rougail/00-base.yml b/structures/20_7help_family/rougail/00-base.yml new file mode 100644 index 0000000..3966db3 --- /dev/null +++ b/structures/20_7help_family/rougail/00-base.yml @@ -0,0 +1,24 @@ +%YAML 1.2 +--- +version: '1.1' + +family1: + description: the first family + help: |- + Multi line + + Help + + With useful information + var: + +family2: + description: the second family + help: >- + Multi line + + Help + + With useful information + var: +... diff --git a/structures/20_9default_information_parent/informations.json b/structures/20_9default_information_parent/informations.json new file mode 100644 index 0000000..3300fa6 --- /dev/null +++ b/structures/20_9default_information_parent/informations.json @@ -0,0 +1 @@ +{"rougail.family": "value"} diff --git a/structures/40_0leadership_reduce/rougail/00-base.yml b/structures/40_0leadership_reduce/rougail/00-base.yml index 5b8acee..abeb7ad 100644 --- a/structures/40_0leadership_reduce/rougail/00-base.yml +++ b/structures/40_0leadership_reduce/rougail/00-base.yml @@ -15,6 +15,9 @@ leadership: test: - val1 - val2 + examples: + - val1 + - val2 follower: # a follower ... diff --git a/structures/44_9calculated_default_leadership_leader/rougail/00-base.yml b/structures/44_9calculated_default_leadership_leader/rougail/00-base.yml index f2c6c9d..8689069 100644 --- a/structures/44_9calculated_default_leadership_leader/rougail/00-base.yml +++ b/structures/44_9calculated_default_leadership_leader/rougail/00-base.yml @@ -13,6 +13,6 @@ leader: {% if _.leader == "a" %} the value of "leader" is "a" {% endif %} - description: if the value of "leader" is "a" + description: if the value of "_.leader" is "a" default: variable: _.leader diff --git a/structures/60_0family_dynamic_jinja_integer_empty/rougail/00-base.yml b/structures/60_0family_dynamic_jinja_integer_empty/rougail/00-base.yml index 4b23203..af8fbe8 100644 --- a/structures/60_0family_dynamic_jinja_integer_empty/rougail/00-base.yml +++ b/structures/60_0family_dynamic_jinja_integer_empty/rougail/00-base.yml @@ -20,4 +20,4 @@ var2: {% if rougail.dyn1 is defined %} {{ rougail.dyn1.var }} {% endif %} - description: get the value of rougail.dyn1.var + description: get the value of "rougail.dyn1.var" diff --git a/structures/60_0family_dynamic_jinja_integer_empty2/force_namespace b/structures/60_0family_dynamic_jinja_integer_empty2/force_namespace new file mode 100644 index 0000000..e69de29 diff --git a/structures/60_0family_dynamic_jinja_integer_empty2/rougail/00-base.yml b/structures/60_0family_dynamic_jinja_integer_empty2/rougail/00-base.yml new file mode 100644 index 0000000..62e3046 --- /dev/null +++ b/structures/60_0family_dynamic_jinja_integer_empty2/rougail/00-base.yml @@ -0,0 +1,23 @@ +--- +version: '1.1' +var: + description: a suffix variable + multi: true + mandatory: false + type: integer + test: + - 1 + - 2 +"dyn{{ identifier }}": + description: a dynamic family + dynamic: + variable: _.var + var: val # a variable inside dynamic family from "{{ identifier }}" +var2: + description: a variable + default: + jinja: | + {% if rougail.dyn1 is defined %} + {{ rougail.dyn1.var }} + {% endif %} + description: get the value of "rougail.dyn1.var" diff --git a/structures/60_0family_dynamic_jinja_number/rougail/00-base.yml b/structures/60_0family_dynamic_jinja_number/rougail/00-base.yml index 47ade72..efd46c3 100644 --- a/structures/60_0family_dynamic_jinja_number/rougail/00-base.yml +++ b/structures/60_0family_dynamic_jinja_number/rougail/00-base.yml @@ -13,4 +13,4 @@ var2: default: jinja: | {{ rougail.dyn1.var }} - description: get the value of rougail.dyn1.var + description: get the value of "rougail.dyn1.var" diff --git a/structures/60_0family_dynamic_variable/rougail/00-base.yml b/structures/60_0family_dynamic_variable/rougail/00-base.yml new file mode 100644 index 0000000..8a64c95 --- /dev/null +++ b/structures/60_0family_dynamic_variable/rougail/00-base.yml @@ -0,0 +1,15 @@ +%YAML 1.2 +--- +version: 1.1 + +var: # A suffix variable + - val1 + - val2 + +dyn{{ identifier }}: + description: A dynamic family + dynamic: + variable: _.var + + variable: # A dynamic variable +... diff --git a/structures/60_2family_dynamic_jinja_fill_sub_group/rougail/00-base.yml b/structures/60_2family_dynamic_jinja_fill_sub_group/rougail/00-base.yml index 82781b8..ed7ffdb 100644 --- a/structures/60_2family_dynamic_jinja_fill_sub_group/rougail/00-base.yml +++ b/structures/60_2family_dynamic_jinja_fill_sub_group/rougail/00-base.yml @@ -14,4 +14,4 @@ var2: default: jinja: | {{ _.dynval1.family.var }} - description: the value of var + description: the value of "_.dynval1.family.var" diff --git a/structures/60_5family_dynamic_calc_description/rougail/00-base.yml b/structures/60_5family_dynamic_calc_description/rougail/00-base.yml new file mode 100644 index 0000000..2fcc59d --- /dev/null +++ b/structures/60_5family_dynamic_calc_description/rougail/00-base.yml @@ -0,0 +1,25 @@ +%YAML 1.2 +--- +version: 1.1 + +dyn{{ identifier }}: + description: a dynamic famify for {{ identifier }} + dynamic: + - val1 + - val2 + + var: + description: a dynamic variable for {{ identifier }} + +var1: + description: a new variable + disabled: + variable: _.dynval1.var + when: 'val' + +var2: + description: a new variable + default: + variable: _.dyn{{ identifier }}.var + unique: false +... diff --git a/structures/60_5family_dynamic_calc_identifier/rougail/00-base.yml b/structures/60_5family_dynamic_calc_identifier/rougail/00-base.yml new file mode 100644 index 0000000..54fb25c --- /dev/null +++ b/structures/60_5family_dynamic_calc_identifier/rougail/00-base.yml @@ -0,0 +1,31 @@ +%YAML 1.2 +--- +version: 1.1 + +var1: + description: A suffix variable + default: + - val1 + - val2 + +var2: + description: A suffix variable2 + default: val1 + hidden: true + +"dyn{{ identifier }}": + dynamic: + variable: _.var1 + + var: + description: A dynamic variable + default: + type: identifier + +var3: + description: A variable calculated + default: + variable: _.dyn{{ identifier }}.var + identifier: + variable: _.var2 +... diff --git a/structures/60_5family_dynamic_calc_identifier_multi/rougail/00-base.yml b/structures/60_5family_dynamic_calc_identifier_multi/rougail/00-base.yml new file mode 100644 index 0000000..440eabd --- /dev/null +++ b/structures/60_5family_dynamic_calc_identifier_multi/rougail/00-base.yml @@ -0,0 +1,32 @@ +%YAML 1.2 +--- +version: 1.1 + +var1: + description: A suffix variable + default: + - val1 + - val2 + +var2: + description: A suffix variable2 + default: val1 + hidden: true + +"dyn{{ identifier }}": + dynamic: + variable: _.var1 + + var: + description: A dynamic variable + multi: true + default: + - type: identifier + +var3: + description: A variable calculated + default: + variable: _.dyn{{ identifier }}.var + identifier: + variable: _.var2 +... diff --git a/structures/60_5family_dynamic_calc_suffix_disabled2/rougail/00-base.yml b/structures/60_5family_dynamic_calc_suffix_disabled2/rougail/00-base.yml index 3e7abb0..14ccbe2 100644 --- a/structures/60_5family_dynamic_calc_suffix_disabled2/rougail/00-base.yml +++ b/structures/60_5family_dynamic_calc_suffix_disabled2/rougail/00-base.yml @@ -5,6 +5,8 @@ var1: description: A suffix variable multi: true mandatory: false + default: + - val1 test: - val1 - val2 @@ -21,4 +23,5 @@ var2: description: A variable calculated default: variable: rougail.dynval1.var - optional: true + propertyerror: false + mandatory: false diff --git a/structures/60_5family_dynamic_calc_suffix_disabled3/force_namespace b/structures/60_5family_dynamic_calc_suffix_disabled3/force_namespace new file mode 100644 index 0000000..e69de29 diff --git a/structures/60_5family_dynamic_calc_suffix_disabled3/rougail/00-base.yml b/structures/60_5family_dynamic_calc_suffix_disabled3/rougail/00-base.yml new file mode 100644 index 0000000..6eff457 --- /dev/null +++ b/structures/60_5family_dynamic_calc_suffix_disabled3/rougail/00-base.yml @@ -0,0 +1,26 @@ +--- +version: '1.1' + +var1: + description: A suffix variable + multi: true + mandatory: false + test: + - val1 + - val2 + +"dyn{{ identifier }}": + dynamic: + variable: _.var1 + + var: + description: A dynamic variable + disabled: true + +var2: + description: A variable calculated + default: + variable: rougail.dynval1.var + optional: true + propertyerror: false + mandatory: false diff --git a/structures/60_5family_dynamic_unknown_suffix/rougail/00-base.yml b/structures/60_5family_dynamic_unknown_suffix/rougail/00-base.yml index 4b8c8ab..86400e9 100644 --- a/structures/60_5family_dynamic_unknown_suffix/rougail/00-base.yml +++ b/structures/60_5family_dynamic_unknown_suffix/rougail/00-base.yml @@ -5,7 +5,7 @@ var: default: - val1 - val2 - test: + examples: - val1 - val2 - val3 diff --git a/structures/60_6family_dynamic_inside_identifier/force_namespace b/structures/60_6family_dynamic_inside_identifier/force_namespace new file mode 100644 index 0000000..e69de29 diff --git a/structures/60_6family_dynamic_inside_identifier/rougail/00-base.yml b/structures/60_6family_dynamic_inside_identifier/rougail/00-base.yml new file mode 100644 index 0000000..40a76b7 --- /dev/null +++ b/structures/60_6family_dynamic_inside_identifier/rougail/00-base.yml @@ -0,0 +1,26 @@ +--- +version: '1.1' +var: # a suffix variable + - val1 + - val2 + +"{{ identifier }}_dyn": + description: a dynamic family + dynamic: + variable: _.var + var1: + description: value is suffix for {{ identifier }} + default: + type: identifier + var2: + description: value is first variable + default: + variable: rougail.{{ identifier }}_dyn.var1 + var3: + description: value is relative first variable + default: + variable: _.var1 + var4: + description: value is first variable of val1 + default: + variable: rougail.val1_dyn.var1 diff --git a/structures/60_6family_dynamic_sub_dynamic/rougail/00-base.yml b/structures/60_6family_dynamic_sub_dynamic/rougail/00-base.yml index f5167dd..e048eec 100644 --- a/structures/60_6family_dynamic_sub_dynamic/rougail/00-base.yml +++ b/structures/60_6family_dynamic_sub_dynamic/rougail/00-base.yml @@ -48,4 +48,4 @@ var: # A identifier variable s2: type: identifier identifier: 1 - description: join identifier 1 et identifier 2 + description: join identifier 1 and identifier 2 diff --git a/structures/60_6family_dynamic_sub_dynamic_1_0/rougail/00-base.yml b/structures/60_6family_dynamic_sub_dynamic_1_0/rougail/00-base.yml index a27b287..9a48d4c 100644 --- a/structures/60_6family_dynamic_sub_dynamic_1_0/rougail/00-base.yml +++ b/structures/60_6family_dynamic_sub_dynamic_1_0/rougail/00-base.yml @@ -51,4 +51,4 @@ var: s2: type: identifier identifier: 1 - description: join identifier 1 et identifier 2 + description: join identifier 1 and identifier 2 diff --git a/structures/60_6family_dynamic_sub_dynamic_empty/rougail/00-base.yml b/structures/60_6family_dynamic_sub_dynamic_empty/rougail/00-base.yml index 2d75041..0ca6778 100644 --- a/structures/60_6family_dynamic_sub_dynamic_empty/rougail/00-base.yml +++ b/structures/60_6family_dynamic_sub_dynamic_empty/rougail/00-base.yml @@ -54,4 +54,4 @@ var: s2: type: identifier identifier: 1 - description: join identifier 1 et identifier 2 + description: join identifier 1 and identifier 2 diff --git a/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml b/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml index 4615655..15d920c 100644 --- a/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml +++ b/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml @@ -47,4 +47,4 @@ var: s2: type: identifier identifier: 1 - description: join identifier 1 et identifier 2 + description: join identifier 1 and identifier 2 diff --git a/structures/60_6family_subdynamic_inside/rougail/00-base.yml b/structures/60_6family_subdynamic_inside/rougail/00-base.yml new file mode 100644 index 0000000..6146806 --- /dev/null +++ b/structures/60_6family_subdynamic_inside/rougail/00-base.yml @@ -0,0 +1,24 @@ +--- +version: 1.1 + +var: + description: A suffix variable + default: + - val1 + - val2 + +dyn{{ identifier }}: + dynamic: + variable: _.var + + dyn{{ identifier }}: + dynamic: + variable: __.var + + var1: # A dynamic variable + + var2: + description: A variable calculated + unique: false + default: + variable: ___.dynval2.dyn{{ identifier }}.var1