2025-11-03 09:15:24 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
from rougail import Rougail
|
2025-12-02 13:59:33 +01:00
|
|
|
from rougail.output_display import RougailOutputDisplay as RougailOutput
|
2025-11-03 09:15:24 +01:00
|
|
|
|
2025-12-03 21:49:02 +01:00
|
|
|
from rougail_tests.utils import get_rougail_config, fake_errors_for_user_data, fake_errors_for_user_data2, fake_dynamic_for_user_data, fake_for_user_data
|
|
|
|
|
|
|
|
|
|
EXT = {'console': 'sh', 'github': 'md'}
|
2025-11-03 09:15:24 +01:00
|
|
|
|
|
|
|
|
|
2025-12-02 13:59:33 +01:00
|
|
|
def test_error_mandatory_hidden():
|
2025-11-03 09:15:24 +01:00
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors/"), namespace=False)
|
2025-12-02 13:59:33 +01:00
|
|
|
rougailconfig['step.output'] = 'display'
|
2025-12-03 21:49:02 +01:00
|
|
|
rougailconfig["display.console.max_width"] = 200
|
2025-11-03 09:15:24 +01:00
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
2025-12-02 13:59:33 +01:00
|
|
|
config.information.set("description_type", "description")
|
2025-11-03 09:15:24 +01:00
|
|
|
config.property.read_only()
|
2025-12-03 21:49:02 +01:00
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors-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}'
|
2025-12-02 13:59:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_error_mandatory_family_hidden():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors2/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
2025-12-03 21:49:02 +01:00
|
|
|
rougailconfig["display.console.max_width"] = 200
|
2025-12-02 13:59:33 +01:00
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
config.property.read_only()
|
2025-12-03 21:49:02 +01:00
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors2-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}'
|
2025-12-02 13:59:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_error_mandatory_family():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors3/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
2025-12-03 21:49:02 +01:00
|
|
|
rougailconfig["display.console.max_width"] = 200
|
2025-12-02 13:59:33 +01:00
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
config.property.read_only()
|
2025-12-03 21:49:02 +01:00
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors3-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_error_not_valid_variable():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors4/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
config.property.read_only()
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors4-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_error_not_valid_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors5/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_errors_for_user_data(), invalid_user_datas_error=True)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors5-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_warning_not_valid_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors5/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_errors_for_user_data())
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == True
|
|
|
|
|
output_file = Path(__file__).parent / 'errors5-1-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_error_not_valid_dyn_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors6/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_dynamic_for_user_data(), invalid_user_datas_error=True, unknown_user_datas_error=True)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors6-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_error_not_valid_dynfamily_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors6/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_for_user_data('dyn{{ identifier }}.var'), invalid_user_datas_error=True, unknown_user_datas_error=True)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors8-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_error_not_valid_family_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors7/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_for_user_data(), invalid_user_datas_error=True, unknown_user_datas_error=True)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors7-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_warnings_not_valid_family_user_data():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors7/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_for_user_data())
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors7-results' / f'display_warnings.{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_error_not_valid_user_data2():
|
|
|
|
|
rougailconfig = get_rougail_config(Path("tests/errors9/"), namespace=False)
|
|
|
|
|
rougailconfig['step.output'] = 'display'
|
|
|
|
|
rougailconfig["display.console.max_width"] = 200
|
|
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
|
config = rougail.run()
|
|
|
|
|
config.information.set("description_type", "description")
|
|
|
|
|
errors = rougail.user_datas(fake_errors_for_user_data2(), invalid_user_datas_error=True)
|
|
|
|
|
for output_format, ext in EXT.items():
|
|
|
|
|
rougailconfig['display.output_format'] = output_format
|
|
|
|
|
no_pb, generated_output = RougailOutput(config, rougailconfig=rougailconfig, user_data_errors=errors["errors"], user_data_warnings=errors["warnings"]).run()
|
|
|
|
|
assert no_pb == False
|
|
|
|
|
output_file = Path(__file__).parent / 'errors9-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}'
|