karl/tests/test_mo.py

35 lines
811 B
Python

from pathlib import Path
import pytest
import yaml
from app.services import Passwords
from app.services.mo import Mo
@pytest.fixture
def target_path():
p = Path('tests/files/test1/test.yaml')
# posprzątaj przed testem, gdyby plik istniał z poprzednich uruchomień
if p.exists():
p.unlink()
yield p
# sprzątanie po teście
if p.exists():
p.unlink()
def test_process(target_path: Path):
mo = Mo(Passwords())
mo.process(Path('tests/files/test1/test.mo.yaml').absolute())
assert target_path.exists()
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'