2026-01-01 09:22:58 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
from rougail import Rougail
|
2026-01-01 21:39:06 +01:00
|
|
|
from tiramisu import MetaConfig
|
2026-01-01 09:22:58 +01:00
|
|
|
from rougail.output_display import RougailOutputDisplay as RougailOutput
|
|
|
|
|
|
|
|
|
|
from rougail_tests.utils import get_rougail_config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXT = {'console': 'sh', 'github': 'md', 'gitlab': 'gitlab.md'}
|
|
|
|
|
|
|
|
|
|
|
2026-01-01 21:39:06 +01:00
|
|
|
def test_layers():
|
2026-01-01 09:22:58 +01:00
|
|
|
layer_datas = {None: {'source1': ['name1', 'name2']}, 'source1.source2': {'source2': ['name3']}, 'source1.source2.source3': {'source3': ['name4']}}
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/layers/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
2026-01-01 21:39:06 +01:00
|
|
|
config = rougail.run(name="source3")
|
|
|
|
|
metaconfig1 = MetaConfig([config], name="source2")
|
|
|
|
|
metaconfig2 = MetaConfig([metaconfig1], name="source1")
|
|
|
|
|
metaconfig2.property.read_only()
|
|
|
|
|
metaconfig1.owner.set(metaconfig1.path())
|
|
|
|
|
metaconfig2.owner.set(metaconfig2.path())
|
|
|
|
|
metaconfig2.information.set("description_type", "description")
|
2026-01-01 09:22:58 +01:00
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
2026-01-01 21:39:06 +01:00
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, layer_datas=layer_datas, root_config=metaconfig2, config_owner_is_path=True).run()
|
2026-01-01 09:22:58 +01:00
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'layers-results' / f'display.{ext}'
|
|
|
|
|
if not output_file.is_file():
|
|
|
|
|
if not output_file.parent.is_dir():
|
|
|
|
|
output_file.parent.mkdir()
|
|
|
|
|
with output_file.open('w') as outfh:
|
|
|
|
|
outfh.write(generated_output)
|
|
|
|
|
with output_file.open() as outfh:
|
|
|
|
|
attented_output = outfh.read()
|
|
|
|
|
assert generated_output == attented_output, f'filename {output_file}'
|
2026-01-01 21:39:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_value(config):
|
|
|
|
|
config.option("a_variable").value.set("a modified value")
|
|
|
|
|
config.option("a_variable").information.set("loaded_from", config.name())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_layers_values_config2():
|
|
|
|
|
layer_datas = {None: {'source1': ['name1', 'name2']}, 'source1.source2': {'source2': ['name3']}, 'source1.source2.source3': {'source3': ['name4']}}
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/layers/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run(name="source3")
|
|
|
|
|
metaconfig1 = MetaConfig([config], name="source2")
|
|
|
|
|
metaconfig2 = MetaConfig([metaconfig1], name="source1")
|
|
|
|
|
metaconfig2.property.read_only()
|
|
|
|
|
metaconfig2.information.set("description_type", "description")
|
|
|
|
|
metaconfig1.owner.set(metaconfig1.path())
|
|
|
|
|
metaconfig2.owner.set(metaconfig2.path())
|
|
|
|
|
set_value(config)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, layer_datas=layer_datas, root_config=metaconfig2, config_owner_is_path=True).run()
|
|
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'layers-values-config-results' / f'display.{ext}'
|
|
|
|
|
if not output_file.is_file():
|
|
|
|
|
if not output_file.parent.is_dir():
|
|
|
|
|
output_file.parent.mkdir()
|
|
|
|
|
with output_file.open('w') as outfh:
|
|
|
|
|
outfh.write(generated_output)
|
|
|
|
|
with output_file.open() as outfh:
|
|
|
|
|
attented_output = outfh.read()
|
|
|
|
|
assert generated_output == attented_output, f'filename {output_file}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_layers_values_metaconfig1():
|
|
|
|
|
layer_datas = {None: {'source1': ['name1', 'name2']}, 'source1.source2': {'source2': ['name3']}, 'source1.source2.source3': {'source3': ['name4']}}
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/layers/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run(name="source3")
|
|
|
|
|
metaconfig1 = MetaConfig([config], name="source2")
|
|
|
|
|
metaconfig2 = MetaConfig([metaconfig1], name="source1")
|
|
|
|
|
metaconfig2.property.read_only()
|
|
|
|
|
metaconfig2.information.set("description_type", "description")
|
|
|
|
|
metaconfig1.owner.set(metaconfig1.path())
|
|
|
|
|
metaconfig2.owner.set(metaconfig2.path())
|
|
|
|
|
set_value(metaconfig1)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, layer_datas=layer_datas, root_config=metaconfig2, config_owner_is_path=True).run()
|
|
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'layers-values-metaconfig1-results' / f'display.{ext}'
|
|
|
|
|
if not output_file.is_file():
|
|
|
|
|
if not output_file.parent.is_dir():
|
|
|
|
|
output_file.parent.mkdir()
|
|
|
|
|
with output_file.open('w') as outfh:
|
|
|
|
|
outfh.write(generated_output)
|
|
|
|
|
with output_file.open() as outfh:
|
|
|
|
|
attented_output = outfh.read()
|
|
|
|
|
assert generated_output == attented_output, f'filename {output_file}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_layers_values_metaconfig2():
|
|
|
|
|
layer_datas = {None: {'source1': ['name1', 'name2']}, 'source1.source2': {'source2': ['name3']}, 'source1.source2.source3': {'source3': ['name4']}}
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/layers/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run(name="source3")
|
|
|
|
|
metaconfig1 = MetaConfig([config], name="source2")
|
|
|
|
|
metaconfig2 = MetaConfig([metaconfig1], name="source1")
|
|
|
|
|
metaconfig2.information.set("description_type", "description")
|
|
|
|
|
metaconfig1.owner.set(metaconfig1.path())
|
|
|
|
|
metaconfig2.owner.set(metaconfig2.path())
|
|
|
|
|
set_value(metaconfig2)
|
|
|
|
|
metaconfig2.property.read_only()
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, layer_datas=layer_datas, root_config=metaconfig2, config_owner_is_path=True).run()
|
|
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'layers-values-metaconfig2-results' / f'display.{ext}'
|
|
|
|
|
if not output_file.is_file():
|
|
|
|
|
if not output_file.parent.is_dir():
|
|
|
|
|
output_file.parent.mkdir()
|
|
|
|
|
with output_file.open('w') as outfh:
|
|
|
|
|
outfh.write(generated_output)
|
|
|
|
|
with output_file.open() as outfh:
|
|
|
|
|
attented_output = outfh.read()
|
|
|
|
|
assert generated_output == attented_output, f'filename {output_file}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_layers_values_metaconfig_mix():
|
|
|
|
|
layer_datas = {None: {'source1': ['name1', 'name2']}, 'source1.source2': {'source2': ['name3']}, 'source1.source2.source3': {'source3': ['name4']}}
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/layers/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run(name="source3")
|
|
|
|
|
metaconfig1 = MetaConfig([config], name="source2")
|
|
|
|
|
metaconfig2 = MetaConfig([metaconfig1], name="source1")
|
|
|
|
|
metaconfig2.information.set("description_type", "description")
|
|
|
|
|
metaconfig1.owner.set(metaconfig1.path())
|
|
|
|
|
metaconfig2.owner.set(metaconfig2.path())
|
|
|
|
|
set_value(config)
|
|
|
|
|
set_value(metaconfig1)
|
|
|
|
|
set_value(metaconfig2)
|
|
|
|
|
metaconfig2.property.read_only()
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, layer_datas=layer_datas, root_config=metaconfig2, config_owner_is_path=True).run()
|
|
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'layers-values-metaconfig-mix-results' / f'display.{ext}'
|
|
|
|
|
if not output_file.is_file():
|
|
|
|
|
if not output_file.parent.is_dir():
|
|
|
|
|
output_file.parent.mkdir()
|
|
|
|
|
with output_file.open('w') as outfh:
|
|
|
|
|
outfh.write(generated_output)
|
|
|
|
|
with output_file.open() as outfh:
|
|
|
|
|
attented_output = outfh.read()
|
|
|
|
|
assert generated_output == attented_output, f'filename {output_file}'
|