fix: support of default_dictionary_format_version file in tests
This commit is contained in:
parent
b229154df5
commit
e7a1caf113
29 changed files with 271 additions and 5 deletions
|
|
@ -270,7 +270,6 @@ PARAM_TYPES = {
|
||||||
|
|
||||||
class Calculation(BaseModel):
|
class Calculation(BaseModel):
|
||||||
path: str
|
path: str
|
||||||
description: Optional[StrictStr] = None
|
|
||||||
inside_list: bool
|
inside_list: bool
|
||||||
version: str
|
version: str
|
||||||
ori_path: Optional[str] = None
|
ori_path: Optional[str] = None
|
||||||
|
|
@ -312,6 +311,7 @@ class JinjaCalculation(Calculation):
|
||||||
jinja: StrictStr
|
jinja: StrictStr
|
||||||
params: Optional[List[Param]] = None
|
params: Optional[List[Param]] = None
|
||||||
return_type: BASETYPE = None
|
return_type: BASETYPE = None
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def _jinja_to_function(
|
def _jinja_to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -570,6 +570,7 @@ class _VariableCalculation(Calculation):
|
||||||
class VariableCalculation(_VariableCalculation):
|
class VariableCalculation(_VariableCalculation):
|
||||||
attribute_name: Literal["default", "choices", "dynamic"]
|
attribute_name: Literal["default", "choices", "dynamic"]
|
||||||
optional: bool = False
|
optional: bool = False
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -607,6 +608,7 @@ class VariablePropertyCalculation(_VariableCalculation):
|
||||||
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
||||||
when: Any = undefined
|
when: Any = undefined
|
||||||
when_not: Any = undefined
|
when_not: Any = undefined
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -661,6 +663,7 @@ class InformationCalculation(Calculation):
|
||||||
attribute_name: Literal["default", "choice", "dynamic"]
|
attribute_name: Literal["default", "choice", "dynamic"]
|
||||||
information: StrictStr
|
information: StrictStr
|
||||||
variable: Optional[StrictStr]
|
variable: Optional[StrictStr]
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -715,6 +718,7 @@ class _IdentifierCalculation(Calculation):
|
||||||
|
|
||||||
class IdentifierCalculation(_IdentifierCalculation):
|
class IdentifierCalculation(_IdentifierCalculation):
|
||||||
attribute_name: Literal["default", "choice", "dynamic"]
|
attribute_name: Literal["default", "choice", "dynamic"]
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -734,6 +738,7 @@ class IdentifierPropertyCalculation(_IdentifierCalculation):
|
||||||
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"]
|
||||||
when: Any = undefined
|
when: Any = undefined
|
||||||
when_not: Any = undefined
|
when_not: Any = undefined
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -768,6 +773,7 @@ class IdentifierPropertyCalculation(_IdentifierCalculation):
|
||||||
|
|
||||||
class IndexCalculation(Calculation):
|
class IndexCalculation(Calculation):
|
||||||
attribute_name: Literal["default", "choice", "dynamic"]
|
attribute_name: Literal["default", "choice", "dynamic"]
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
@ -784,6 +790,7 @@ class IndexCalculation(Calculation):
|
||||||
|
|
||||||
class NamespaceCalculation(Calculation):
|
class NamespaceCalculation(Calculation):
|
||||||
attribute_name: Literal["default", "secret_manager"]
|
attribute_name: Literal["default", "secret_manager"]
|
||||||
|
description: Optional[StrictStr] = None
|
||||||
|
|
||||||
def to_function(
|
def to_function(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
1
tests/dictionaries/00_0no_variable/makedict/after.json
Normal file
1
tests/dictionaries/00_0no_variable/makedict/after.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
1
tests/dictionaries/00_0no_variable/makedict/base.json
Normal file
1
tests/dictionaries/00_0no_variable/makedict/base.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
1
tests/dictionaries/00_0no_variable/makedict/before.json
Normal file
1
tests/dictionaries/00_0no_variable/makedict/before.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
14
tests/dictionaries/00_0no_variable/tiramisu/base.py
Normal file
14
tests/dictionaries/00_0no_variable/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
["rougail.var1", "rougail.var2"]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": null,
|
||||||
|
"rougail.var2": null
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"rougail.dynval1.var": true,
|
||||||
|
"rougail.dynval2.var": true,
|
||||||
|
"rougail.var2": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"rougail.var2": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"rougail.dynval1.var": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
],
|
||||||
|
"rougail.dynval2.var": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
],
|
||||||
|
"rougail.var2": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.var2": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"rougail.var2": [
|
||||||
|
"a value",
|
||||||
|
"a second value"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ for test in errors_dirs.iterdir():
|
||||||
test_raise.add(test.name)
|
test_raise.add(test.name)
|
||||||
|
|
||||||
excludes = set([
|
excludes = set([
|
||||||
'80family_several',
|
# '80family_several',
|
||||||
])
|
])
|
||||||
test_ok -= excludes
|
test_ok -= excludes
|
||||||
test_raise -= excludes
|
test_raise -= excludes
|
||||||
|
|
@ -149,6 +149,10 @@ def test_dictionary(test_dir):
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
if (dico_dirs / test_dir / 'force_namespace').is_file():
|
if (dico_dirs / test_dir / 'force_namespace').is_file():
|
||||||
return
|
return
|
||||||
|
if (dico_dirs / test_dir / 'default_dictionary_format_version').is_file():
|
||||||
|
rougailconfig['default_dictionary_format_version'] = "1.1"
|
||||||
|
else:
|
||||||
|
rougailconfig['default_dictionary_format_version'] = None
|
||||||
eolobj = load_rougail_object(str(dico_dirs / test_dir), rougailconfig)
|
eolobj = load_rougail_object(str(dico_dirs / test_dir), rougailconfig)
|
||||||
if not eolobj:
|
if not eolobj:
|
||||||
return
|
return
|
||||||
|
|
@ -166,6 +170,10 @@ def test_dictionary_namespace(test_dir):
|
||||||
rougailconfig['main_namespace'] = 'Rougail'
|
rougailconfig['main_namespace'] = 'Rougail'
|
||||||
if (dico_dirs / test_dir / 'force_no_namespace').is_file():
|
if (dico_dirs / test_dir / 'force_no_namespace').is_file():
|
||||||
return
|
return
|
||||||
|
if (dico_dirs / test_dir / 'default_dictionary_format_version').is_file():
|
||||||
|
rougailconfig['default_dictionary_format_version'] = "1.1"
|
||||||
|
else:
|
||||||
|
rougailconfig['default_dictionary_format_version'] = None
|
||||||
eolobj = load_rougail_object(test_dir_, rougailconfig, namespace=True)
|
eolobj = load_rougail_object(test_dir_, rougailconfig, namespace=True)
|
||||||
if not eolobj:
|
if not eolobj:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ def test_validate_default_version():
|
||||||
RougailConfig["dictionaries_dir"] = ["tests/data/dict1"]
|
RougailConfig["dictionaries_dir"] = ["tests/data/dict1"]
|
||||||
RougailConfig["default_dictionary_format_version"] = "1.1"
|
RougailConfig["default_dictionary_format_version"] = "1.1"
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.get_config()
|
config = rougail.run()
|
||||||
|
|
||||||
filename = "tests/data/dict1/dict.yml"
|
filename = "tests/data/dict1/dict.yml"
|
||||||
with open(filename, encoding="utf8") as file_fh:
|
with open(filename, encoding="utf8") as file_fh:
|
||||||
|
|
@ -55,7 +55,7 @@ def test_validate_file_version_from_yml():
|
||||||
RougailConfig["dictionaries_dir"] = ["tests/data/dict2"]
|
RougailConfig["dictionaries_dir"] = ["tests/data/dict2"]
|
||||||
RougailConfig["default_dictionary_format_version"] = "1.1"
|
RougailConfig["default_dictionary_format_version"] = "1.1"
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.get_config()
|
config = rougail.run()
|
||||||
|
|
||||||
filename = "tests/data/dict2/dict.yml"
|
filename = "tests/data/dict2/dict.yml"
|
||||||
with open(filename, encoding="utf8") as file_fh:
|
with open(filename, encoding="utf8") as file_fh:
|
||||||
|
|
@ -71,7 +71,7 @@ def test_retrieve_version_from_config():
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
# FIXME replace with rougail.annotator()
|
# FIXME replace with rougail.annotator()
|
||||||
# rougail.converted.annotator()
|
# rougail.converted.annotator()
|
||||||
rougail.get_config()
|
rougail.run()
|
||||||
assert rougail.converted.paths._data["rougail.hello"].version == "1.0"
|
assert rougail.converted.paths._data["rougail.hello"].version == "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue