Files
nvi/tests/test_prompts.py

31 lines
832 B
Python

"""Regression: every prompt file loads, render() substitutes placeholders."""
from pathlib import Path
import pytest
from api.prompts import PROMPTS_DIR, load, render
PROMPT_NAMES = sorted(
p.stem for p in PROMPTS_DIR.iterdir() if p.suffix == ".txt"
)
@pytest.mark.parametrize("name", PROMPT_NAMES)
def test_prompt_loads(name):
text = load(name)
assert text # non-empty
def test_render_substitutes():
out = render("synthesize.user", question="how many?", findings_block="x: 1")
assert "how many?" in out
assert "x: 1" in out
assert "{question}" not in out and "{findings_block}" not in out
def test_render_unknown_placeholder_raises():
# str.format raises KeyError on missing keys
with pytest.raises(KeyError):
render("synthesize.user", question="q") # missing findings_block