48 lines
1 KiB
Python
48 lines
1 KiB
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()
|
|
|
|
|
|
@pytest.fixture
|
|
def test1_content(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
|
|
|
|
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'
|