From ed1ee9e8a6db13fb1df7b7775ec6cb2db5cea809 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 18 May 2021 18:32:01 +0200 Subject: [PATCH] can disable a service from an extra --- src/rougail/path.py | 1 + .../70service_servicelist_extra/00-base.xml | 6 ++++++ .../70service_servicelist_extra/__init__.py | 0 .../extra_dirs/extra/00-base.xml | 14 +++++++++++++ .../makedict/after.json | 14 +++++++++++++ .../makedict/base.json | 5 +++++ .../makedict/before.json | 14 +++++++++++++ .../tiramisu/base.py | 20 +++++++++++++++++++ 8 files changed, 74 insertions(+) create mode 100644 tests/dictionaries/70service_servicelist_extra/00-base.xml create mode 100644 tests/dictionaries/70service_servicelist_extra/__init__.py create mode 100644 tests/dictionaries/70service_servicelist_extra/extra_dirs/extra/00-base.xml create mode 100644 tests/dictionaries/70service_servicelist_extra/makedict/after.json create mode 100644 tests/dictionaries/70service_servicelist_extra/makedict/base.json create mode 100644 tests/dictionaries/70service_servicelist_extra/makedict/before.json create mode 100644 tests/dictionaries/70service_servicelist_extra/tiramisu/base.py diff --git a/src/rougail/path.py b/src/rougail/path.py index 3a44e7200..a4a38762f 100644 --- a/src/rougail/path.py +++ b/src/rougail/path.py @@ -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') diff --git a/tests/dictionaries/70service_servicelist_extra/00-base.xml b/tests/dictionaries/70service_servicelist_extra/00-base.xml new file mode 100644 index 000000000..b503d8d63 --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/00-base.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/dictionaries/70service_servicelist_extra/__init__.py b/tests/dictionaries/70service_servicelist_extra/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/70service_servicelist_extra/extra_dirs/extra/00-base.xml b/tests/dictionaries/70service_servicelist_extra/extra_dirs/extra/00-base.xml new file mode 100644 index 000000000..b5869d642 --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/extra_dirs/extra/00-base.xml @@ -0,0 +1,14 @@ + + + + + no + + + + + yes + test + + + diff --git a/tests/dictionaries/70service_servicelist_extra/makedict/after.json b/tests/dictionaries/70service_servicelist_extra/makedict/after.json new file mode 100644 index 000000000..2e714b700 --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/makedict/after.json @@ -0,0 +1,14 @@ +{ + "extra.condition": { + "owner": "default", + "value": "no" + }, + "services.test.activate": { + "owner": "default", + "value": true + }, + "services.test.manage": { + "owner": "default", + "value": true + } +} diff --git a/tests/dictionaries/70service_servicelist_extra/makedict/base.json b/tests/dictionaries/70service_servicelist_extra/makedict/base.json new file mode 100644 index 000000000..d0a40a85c --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/makedict/base.json @@ -0,0 +1,5 @@ +{ + "extra.condition": "no", + "services.test.activate": true, + "services.test.manage": true +} diff --git a/tests/dictionaries/70service_servicelist_extra/makedict/before.json b/tests/dictionaries/70service_servicelist_extra/makedict/before.json new file mode 100644 index 000000000..2e714b700 --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/makedict/before.json @@ -0,0 +1,14 @@ +{ + "extra.condition": { + "owner": "default", + "value": "no" + }, + "services.test.activate": { + "owner": "default", + "value": true + }, + "services.test.manage": { + "owner": "default", + "value": true + } +} diff --git a/tests/dictionaries/70service_servicelist_extra/tiramisu/base.py b/tests/dictionaries/70service_servicelist_extra/tiramisu/base.py new file mode 100644 index 000000000..d6cc441bc --- /dev/null +++ b/tests/dictionaries/70service_servicelist_extra/tiramisu/base.py @@ -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])