feat: update tests
This commit is contained in:
parent
e7f017c72e
commit
164f4c11a2
38 changed files with 416 additions and 17 deletions
|
|
@ -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': {}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ var2:
|
|||
{% for val in _.var1 %}
|
||||
{{ val }}
|
||||
{% endfor %}
|
||||
description: the value of _.var1
|
||||
description: the value of "_.var1"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ secret1:
|
|||
type: secret
|
||||
params:
|
||||
min_len: 10
|
||||
examples:
|
||||
- ALongS4cr4t
|
||||
secret2:
|
||||
description: the second variable
|
||||
type: secret
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ variable:
|
|||
description: a variable
|
||||
default:
|
||||
jinja: |
|
||||
{{test_information }}
|
||||
{{ test_information }}
|
||||
params:
|
||||
test_information:
|
||||
type: information
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
{"rougail.var": "value"}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"rougail.var1": "value"}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"rougail.var1": "value"}
|
||||
21
structures/01_6string_multi_length/rougail/00-base.yml
Normal file
21
structures/01_6string_multi_length/rougail/00-base.yml
Normal file
|
|
@ -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
|
||||
18
structures/04_1jinja_and_hidden/rougail/00-base.yml
Normal file
18
structures/04_1jinja_and_hidden/rougail/00-base.yml
Normal file
|
|
@ -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
|
||||
...
|
||||
|
|
@ -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
|
||||
...
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
version: '1.1'
|
||||
condition:
|
||||
description: a condition
|
||||
default: true
|
||||
disabled: true
|
||||
variable:
|
||||
description: a variable
|
||||
disabled:
|
||||
variable: _.condition
|
||||
propertyerror: transitive
|
||||
|
|
@ -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
|
||||
...
|
||||
|
|
@ -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
|
||||
...
|
||||
24
structures/20_7help_family/rougail/00-base.yml
Normal file
24
structures/20_7help_family/rougail/00-base.yml
Normal file
|
|
@ -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:
|
||||
...
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"rougail.family": "value"}
|
||||
|
|
@ -15,6 +15,9 @@ leadership:
|
|||
test:
|
||||
- val1
|
||||
- val2
|
||||
examples:
|
||||
- val1
|
||||
- val2
|
||||
|
||||
follower: # a follower
|
||||
...
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
15
structures/60_0family_dynamic_variable/rougail/00-base.yml
Normal file
15
structures/60_0family_dynamic_variable/rougail/00-base.yml
Normal file
|
|
@ -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
|
||||
...
|
||||
|
|
@ -14,4 +14,4 @@ var2:
|
|||
default:
|
||||
jinja: |
|
||||
{{ _.dynval1.family.var }}
|
||||
description: the value of var
|
||||
description: the value of "_.dynval1.family.var"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
...
|
||||
|
|
@ -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
|
||||
...
|
||||
|
|
@ -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
|
||||
...
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -5,7 +5,7 @@ var:
|
|||
default:
|
||||
- val1
|
||||
- val2
|
||||
test:
|
||||
examples:
|
||||
- val1
|
||||
- val2
|
||||
- val3
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -51,4 +51,4 @@ var:
|
|||
s2:
|
||||
type: identifier
|
||||
identifier: 1
|
||||
description: join identifier 1 et identifier 2
|
||||
description: join identifier 1 and identifier 2
|
||||
|
|
|
|||
|
|
@ -54,4 +54,4 @@ var:
|
|||
s2:
|
||||
type: identifier
|
||||
identifier: 1
|
||||
description: join identifier 1 et identifier 2
|
||||
description: join identifier 1 and identifier 2
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ var:
|
|||
s2:
|
||||
type: identifier
|
||||
identifier: 1
|
||||
description: join identifier 1 et identifier 2
|
||||
description: join identifier 1 and identifier 2
|
||||
|
|
|
|||
24
structures/60_6family_subdynamic_inside/rougail/00-base.yml
Normal file
24
structures/60_6family_subdynamic_inside/rougail/00-base.yml
Normal file
|
|
@ -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
|
||||
Loading…
Reference in a new issue