test: cleanup

This commit is contained in:
Piotr Dec 2025-11-25 01:22:08 +01:00
parent 082ab463c1
commit 227d8107aa
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
4 changed files with 48 additions and 31 deletions

View file

@ -2,3 +2,4 @@ value: ${sample}
nested: ${some.nested.value}
custom: ${custom/field}
uname: ${sample/username}
invalid: ${double/slash/example}

View file

@ -7,7 +7,7 @@ from app.services import Passwords
from app.services.mo import Mo
@pytest.fixture
@pytest.fixture(scope='class')
def target_path():
p = Path('tests/files/test1/test.yaml')
# posprzątaj przed testem, gdyby plik istniał z poprzednich uruchomień
@ -19,7 +19,7 @@ def target_path():
p.unlink()
@pytest.fixture
@pytest.fixture(scope='class')
def test1_content(target_path: Path):
mo = Mo(Passwords())
mo.process(Path('tests/files/test1/test.mo.yaml').absolute())
@ -29,20 +29,22 @@ def test1_content(target_path: Path):
content = target_path.read_text()
assert '${' not in content
return yaml.load(content, Loader=yaml.FullLoader)
yield yaml.load(content, Loader=yaml.FullLoader)
def test_simple(test1_content: dict):
assert test1_content['value'] == 'some_pass'
class TestParsing:
def test_simple(self, test1_content: dict):
assert test1_content['value'] == 'some_pass'
def test_nested(test1_content: dict):
assert test1_content['nested'] == 'nested_pass'
def test_nested(self, test1_content: dict):
assert test1_content['nested'] == 'nested_pass'
def test_custom_field(self, test1_content: dict):
assert test1_content['custom'] == 'custom_content'
def test_custom_field(test1_content: dict):
assert test1_content['custom'] == 'custom_content'
def test_username_field(self, test1_content: dict):
assert test1_content['uname'] == 'sample_username'
def test_username_field(test1_content: dict):
assert test1_content['uname'] == 'sample_username'
def test_invalid_key(self, test1_content: dict):
assert test1_content.get('invalid') == 'None'