fix: add error tests
This commit is contained in:
parent
871a0932f5
commit
53c7d29585
13 changed files with 107 additions and 7 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12
tests/errors/duplicate/rougail/00-file.yml
Normal file
12
tests/errors/duplicate/rougail/00-file.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
family_1: # A family
|
||||||
|
|
||||||
|
variable: # A variable
|
||||||
|
|
||||||
|
family_2: # An other family
|
||||||
|
|
||||||
|
variable: # A variable
|
||||||
|
...
|
||||||
8
tests/errors/multi_separator/rougail/00-file.yml
Normal file
8
tests/errors/multi_separator/rougail/00-file.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
variable: # A variable
|
||||||
|
- val1
|
||||||
|
- val;2
|
||||||
|
...
|
||||||
20
tests/errors/multi_separator2/rougail/00-file.yml
Normal file
20
tests/errors/multi_separator2/rougail/00-file.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
description: A sequence
|
||||||
|
type: sequence
|
||||||
|
|
||||||
|
variable1:
|
||||||
|
description: A variable 1
|
||||||
|
default:
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
|
||||||
|
variable2:
|
||||||
|
description: A variable 2
|
||||||
|
default:
|
||||||
|
- val1
|
||||||
|
- val;2
|
||||||
|
...
|
||||||
20
tests/errors/submulti_separator/rougail/00-file.yml
Normal file
20
tests/errors/submulti_separator/rougail/00-file.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
description: A sequence
|
||||||
|
type: sequence
|
||||||
|
|
||||||
|
variable1:
|
||||||
|
description: A variable 1
|
||||||
|
default:
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
|
||||||
|
variable2:
|
||||||
|
description: A variable 2
|
||||||
|
default:
|
||||||
|
- val1
|
||||||
|
- val,2
|
||||||
|
...
|
||||||
43
tests/test_error.py
Normal file
43
tests/test_error.py
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
from pathlib import Path
|
||||||
|
from pytest import raises
|
||||||
|
from rougail_tests.utils import get_rougail_config, get_values_for_config
|
||||||
|
#########################
|
||||||
|
from rougail.output_environment import RougailOutputEnvironment as RougailOutput
|
||||||
|
#########################
|
||||||
|
from rougail.error import ExtensionError
|
||||||
|
from rougail import Rougail
|
||||||
|
|
||||||
|
|
||||||
|
def _test_error(test_dir):
|
||||||
|
rougailconfig = get_rougail_config(test_dir, False)
|
||||||
|
if not rougailconfig:
|
||||||
|
return
|
||||||
|
# rougailconfig['tiramisu_cache'] = "cache.py"
|
||||||
|
##################################
|
||||||
|
rougailconfig['step.output'] = 'environment'
|
||||||
|
rougailconfig["environment.output.path_is_variable_name"] = False
|
||||||
|
rougailconfig["environment.output.multi_in_array"] = False
|
||||||
|
##################################
|
||||||
|
rougail = Rougail(rougailconfig)
|
||||||
|
config = rougail.run()
|
||||||
|
##################################
|
||||||
|
get_values_for_config(config, level="mandatory")
|
||||||
|
##################################
|
||||||
|
with raises(ExtensionError):
|
||||||
|
RougailOutput(config, rougailconfig=rougailconfig).run()
|
||||||
|
|
||||||
|
|
||||||
|
def test_error_duplicate():
|
||||||
|
_test_error(Path("tests/errors/duplicate"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_error_multi_separator():
|
||||||
|
_test_error(Path("tests/errors/multi_separator"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_error_multi_separator2():
|
||||||
|
_test_error(Path("tests/errors/multi_separator2"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_error_submulti_separator():
|
||||||
|
_test_error(Path("tests/errors/submulti_separator"))
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
import os
|
|
||||||
from pytest import fixture, raises
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from rougail import Rougail, RougailConfig
|
from pytest import fixture
|
||||||
|
from rougail_tests.utils import get_structures_list, get_rougail_config, get_values_for_config
|
||||||
#########################
|
#########################
|
||||||
from rougail.output_environment import RougailOutputEnvironment as RougailOutput
|
from rougail.output_environment import RougailOutputEnvironment as RougailOutput
|
||||||
from json import load, dump
|
|
||||||
#########################
|
#########################
|
||||||
|
from rougail import Rougail
|
||||||
from rougail_tests.utils import get_structures_list, get_rougail_config, get_values_for_config, config_to_dict
|
|
||||||
|
|
||||||
EXT = "env"
|
EXT = "env"
|
||||||
|
|
||||||
|
|
@ -64,7 +61,7 @@ def _test_structural_files(test_dir, namespace, ext, change=False):
|
||||||
with output_file.open('w') as outfh:
|
with output_file.open('w') as outfh:
|
||||||
outfh.write(generated_output)
|
outfh.write(generated_output)
|
||||||
with output_file.open() as outfh:
|
with output_file.open() as outfh:
|
||||||
attented_output = outfh.read()
|
attented_output = outfh.read()
|
||||||
assert generated_output == attented_output, f'filename {output_file}'
|
assert generated_output == attented_output, f'filename {output_file}'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue