Skip to content

Commit f86470b

Browse files
committed
Add test_template_render_hello() to increase test cov
1 parent 3b3f315 commit f86470b

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

tests/__snapshots__/test_template_cmd.ambr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# serializer version: 1
2-
# name: test_template_render[YAMLConfigFile]
2+
# name: test_template_render_day_log[YAMLConfigFile]
33
'''
44
# 1991-03-04.Mon
55
#

tests/data/hello_tmpl.zo

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Template for saying hi to different people!
2+
3+
Hello {{ first_name }} {{ last_name }}

tests/test_template_cmd.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
from . import common as c
1111

1212

13-
def test_template_render(
13+
def test_template_render_day_log(
1414
main: c.MainType,
1515
capsys: CaptureFixture,
1616
tmp_path: Path,
1717
snapshot: Snapshot,
1818
) -> None:
19-
"""Test the 'template render' subcommand."""
19+
"""Test that the 'day_log_tmpl.zo' template renders as expected."""
2020
zettel_dir = tmp_path / "org"
2121
zot_basename = "day_log_tmpl.zo"
2222
template_path: Path = zettel_dir / zot_basename
@@ -38,3 +38,33 @@ def test_template_render(
3838

3939
capture = capsys.readouterr()
4040
assert capture.out == snapshot
41+
42+
43+
def test_template_render_hello(
44+
main: c.MainType,
45+
capsys: CaptureFixture,
46+
tmp_path: Path,
47+
) -> None:
48+
"""Test that the 'hello_tmpl.zo' template renders as expected."""
49+
zettel_dir = tmp_path / "org"
50+
zot_basename = "hello_tmpl.zo"
51+
template_path: Path = zettel_dir / zot_basename
52+
template_path.parent.mkdir(parents=True, exist_ok=True)
53+
test_data_template_path = Path(__file__).parent / Path(
54+
f"data/{zot_basename}"
55+
)
56+
template_path.write_text(test_data_template_path.read_text())
57+
58+
argv = [
59+
"--dir",
60+
str(zettel_dir),
61+
"template",
62+
"render",
63+
zot_basename,
64+
"first_name=John",
65+
"last_name=Smith",
66+
]
67+
assert main(*argv) == 0
68+
69+
capture = capsys.readouterr()
70+
assert capture.out == "Hello John Smith\n"

0 commit comments

Comments
 (0)