From 082ab463c1a41fef2dd4c1deae9dee58a449706c Mon Sep 17 00:00:00 2001 From: Piotr Dec Date: Mon, 24 Nov 2025 18:56:08 +0100 Subject: [PATCH] test: new field convention TDD --- tests/files/test1/test.mo.yaml | 7 ++++--- tests/test_mo.py | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/files/test1/test.mo.yaml b/tests/files/test1/test.mo.yaml index c494bd1..f2aaac7 100644 --- a/tests/files/test1/test.mo.yaml +++ b/tests/files/test1/test.mo.yaml @@ -1,3 +1,4 @@ -value: %{sample} -nested: %{some.nested.value} -custom: ${custom.field} +value: ${sample} +nested: ${some.nested.value} +custom: ${custom/field} +uname: ${sample/username} diff --git a/tests/test_mo.py b/tests/test_mo.py index e9f54d0..8237e8d 100644 --- a/tests/test_mo.py +++ b/tests/test_mo.py @@ -19,7 +19,8 @@ def target_path(): p.unlink() -def test_process(target_path: Path): +@pytest.fixture +def test1_content(target_path: Path): mo = Mo(Passwords()) mo.process(Path('tests/files/test1/test.mo.yaml').absolute()) @@ -27,9 +28,21 @@ def test_process(target_path: Path): content = target_path.read_text() assert '${' not in content - assert '%{' not in content - parsed = yaml.load(content, Loader=yaml.FullLoader) - assert parsed['value'] == 'some_pass' - assert parsed['nested'] == 'nested_pass' - assert parsed['custom'] == 'custom_content' + return yaml.load(content, Loader=yaml.FullLoader) + + +def test_simple(test1_content: dict): + assert test1_content['value'] == 'some_pass' + + +def test_nested(test1_content: dict): + assert test1_content['nested'] == 'nested_pass' + + +def test_custom_field(test1_content: dict): + assert test1_content['custom'] == 'custom_content' + + +def test_username_field(test1_content: dict): + assert test1_content['uname'] == 'sample_username'