can disable a service from an extra

This commit is contained in:
Emmanuel Garette 2021-05-18 18:32:01 +02:00
parent ddf33faf91
commit ed1ee9e8a6
8 changed files with 74 additions and 0 deletions

View File

@ -174,6 +174,7 @@ class Path:
)
namespace = dico['variableobj'].namespace
if namespace not in [self.variable_namespace, 'services'] and \
current_namespace != 'services' and \
current_namespace != namespace:
msg = _(f'A variable located in the "{namespace}" namespace shall not be used '
f'in the "{current_namespace}" namespace')

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="test" servicelist="test"/>
</services>
</rougail>

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<variable name="condition">
<value>no</value>
</variable>
</variables>
<constraints>
<condition name="disabled_if_in" source="extra.condition">
<param>yes</param>
<target type="servicelist">test</target>
</condition>
</constraints>
</rougail>

View File

@ -0,0 +1,14 @@
{
"extra.condition": {
"owner": "default",
"value": "no"
},
"services.test.activate": {
"owner": "default",
"value": true
},
"services.test.manage": {
"owner": "default",
"value": true
}
}

View File

@ -0,0 +1,5 @@
{
"extra.condition": "no",
"services.test.activate": true,
"services.test.manage": true
}

View File

@ -0,0 +1,14 @@
{
"extra.condition": {
"owner": "default",
"value": "no"
},
"services.test.activate": {
"owner": "default",
"value": true
},
"services.test.manage": {
"owner": "default",
"value": true
}
}

View File

@ -0,0 +1,20 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
loader = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
spec = spec_from_loader(loader.name, loader)
func = module_from_spec(spec)
loader.exec_module(func)
for key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
option_2 = StrOption(name="condition", doc="condition", default="no", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="extra", doc="extra", children=[option_2])
option_5 = BoolOption(name="activate", doc="activate", default=Calculation(func.calc_value, Params((ParamValue(False)), kwargs={'default': ParamValue(True), 'condition_0': ParamOption(option_2, notraisepropertyerror=True), 'expected_0': ParamValue("yes")})))
option_6 = BoolOption(name="manage", doc="manage", default=True)
option_4 = OptionDescription(name="test", doc="test", children=[option_5, option_6])
option_3 = OptionDescription(name="services", doc="services", children=[option_4], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_3])