mirror of
https://github.com/copier-org/copier.git
synced 2025-05-05 23:42:55 +00:00
test: add test case for merging settings
The test case checks that merging entries for the the settings `skip_if_exists`, `exclude`, `jinja_extensions` and `secret_questions` work as expected and entries are concatenated.
This commit is contained in:
parent
ef10e6b53a
commit
f643d846cd
10
tests/demo_merge_options_from_answerfiles/copier.yml
Normal file
10
tests/demo_merge_options_from_answerfiles/copier.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
_skip_if_exists:
|
||||||
|
- skip_if_exists0
|
||||||
|
|
||||||
|
_jinja_extensions:
|
||||||
|
- jinja2.ext.0
|
||||||
|
|
||||||
|
---
|
||||||
|
!include ./include1.yml
|
||||||
|
---
|
||||||
|
!include ./include2.yml
|
8
tests/demo_merge_options_from_answerfiles/include1.yml
Normal file
8
tests/demo_merge_options_from_answerfiles/include1.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
_skip_if_exists:
|
||||||
|
- skip_if_exists1
|
||||||
|
|
||||||
|
_secret_questions:
|
||||||
|
- question1
|
||||||
|
|
||||||
|
_exclude:
|
||||||
|
- exclude1
|
9
tests/demo_merge_options_from_answerfiles/include2.yml
Normal file
9
tests/demo_merge_options_from_answerfiles/include2.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
_skip_if_exists:
|
||||||
|
- skip_if_exists2
|
||||||
|
|
||||||
|
_jinja_extensions:
|
||||||
|
- jinja2.ext.2
|
||||||
|
|
||||||
|
_exclude:
|
||||||
|
- exclude21
|
||||||
|
- exclude22
|
@ -43,6 +43,18 @@ def test_config_data_is_loaded_from_file():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_data_is_merged_from_files():
|
||||||
|
tpl = Template("tests/demo_merge_options_from_answerfiles")
|
||||||
|
assert list(tpl.skip_if_exists) == [
|
||||||
|
"skip_if_exists0",
|
||||||
|
"skip_if_exists1",
|
||||||
|
"skip_if_exists2",
|
||||||
|
]
|
||||||
|
assert list(tpl.exclude) == ["exclude1", "exclude21", "exclude22"]
|
||||||
|
assert list(tpl.jinja_extensions) == ["jinja2.ext.0", "jinja2.ext.2"]
|
||||||
|
assert list(tpl.secret_questions) == ["question1"]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("config_suffix", ["yaml", "yml"])
|
@pytest.mark.parametrize("config_suffix", ["yaml", "yml"])
|
||||||
def test_read_data(tmp_path_factory, config_suffix):
|
def test_read_data(tmp_path_factory, config_suffix):
|
||||||
src, dst = map(tmp_path_factory.mktemp, ("src", "dst"))
|
src, dst = map(tmp_path_factory.mktemp, ("src", "dst"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user