20 lines
474 B
Python
20 lines
474 B
Python
import pytest
|
|
|
|
from app.templates import safe_render
|
|
|
|
|
|
def test_safe_render_legacy_and_nested():
|
|
tpl = "收到{actual_ref_amt}元 by {trans_order_info.remark}"
|
|
ctx = {"actual_ref_amt": 88.88, "trans_order_info": {"remark": "order123"}}
|
|
out = safe_render(tpl, ctx)
|
|
assert "88.88" in out
|
|
assert "order123" in out
|
|
|
|
|
|
def test_safe_render_missing_var_raises():
|
|
tpl = "Hello {missing_var}"
|
|
with pytest.raises(Exception):
|
|
safe_render(tpl, {})
|
|
|
|
|