Simple/Complex templates / parsers

This commit is contained in:
Piotr Dec 2025-11-03 21:56:59 +01:00
parent e3a37419e8
commit 3dc27cc868
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
4 changed files with 38 additions and 19 deletions

View file

@ -1,3 +1,3 @@
value: ${sample.password}
nested: ${some.nested.value.password}
custom: ${custom.field}
value: ${sample}
nested: ${some.nested.value}
custom: @{custom.field}

View file

@ -10,18 +10,14 @@ from app.services.mo import Mo
class TestMo(TestCase):
def test_process(self):
target_path = Path('tests/files/test1/test.yaml')
mo = Mo(Passwords())
mo.process(Path('tests/files/test1/test.mo.yaml').absolute())
self.assertTrue(os.path.exists('tests/files/test1/test.mo'))
with open('tests/files/test1/test.yaml', 'r') as f:
self.assertTrue(os.path.exists(target_path))
with open(target_path, 'r') as f:
content = f.read()
self.assertFalse(content.__contains__('${'))
parsed = yaml.load(content, Loader=yaml.FullLoader)
self.assertEqual(parsed['value'], 'some_oass')
self.assertEqual(parsed['nested'], 'nested_pass')
self.assertEqual(parsed['custom'], 'custom_content')
"""
value: some_oass
nested: nested_pass
custom: custom_content
"""
self.assertEqual('some_pass', parsed['value'])
self.assertEqual('nested_pass', parsed['nested'])
self.assertEqual('custom_content', parsed['custom'])