large refactor (break up ConfigManager), add more tests

This commit is contained in:
2024-08-10 23:48:35 -07:00
parent cb1dd52833
commit bf311d57a5
26 changed files with 1066 additions and 611 deletions

31
tests/test_template.py Normal file
View File

@@ -0,0 +1,31 @@
from pathlib import Path
from symconf import Template, TOMLTemplate
def test_template_fill():
# test simple replacment
assert Template('f{{a}} - f{{b}}').fill({
'a': 1,
'b': 2,
}) == '1 - 2'
# test nested brackets (using default pattern)
assert Template('{{ f{{a}} - f{{b}} }}').fill({
'a': 1,
'b': 2,
}) == '{{ 1 - 2 }}'
# test tight nested brackets (requires greedy quantifier)
assert Template('{{f{{a}} - f{{b}}}}').fill({
'a': 1,
'b': 2,
}) == '{{1 - 2}}'
def test_toml_template_fill():
test_group_dir = Path(
__file__, '..', 'test-config-dir/groups/test/'
).resolve()
stacked_dict = TOMLTemplate.stack_toml(test_group_dir.iterdir())
assert stacked_dict == {'base':'aaa','concrete':'zzz'}