Skip to content

Commit 0af34b1

Browse files
committed
refactor(chapter08): rename zznew to emit_photo_data for clarity in photo rendering
1 parent 8df8cc7 commit 0af34b1

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

chapter08/src/case03/case03.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def render_person(out_stream, person):
33
result.append(f"<p>{person['name']}</p>")
44
result.append(render_photo(person["photo"]))
55
result.append(f"<p>title: {person['photo']['title']}</p>")
6-
result.append(zznew(person["photo"]))
6+
result.append(emit_photo_data(person["photo"]))
77
return "\n".join(result)
88

99

@@ -15,24 +15,17 @@ def photo_div(p):
1515
return "\n".join(
1616
[
1717
"<div>",
18-
zznew(p),
18+
emit_photo_data(p),
1919
"</div>",
2020
]
2121
)
2222

2323

24-
def zznew(p):
24+
def emit_photo_data(p):
2525
return "\n".join(
2626
[
2727
f"<p>title: {p['title']}</p>",
2828
f"<p>location: {p['location']}</p>",
2929
f"<p>date: {p['date'].strftime('%Y-%m-%d')}</p>",
3030
]
3131
)
32-
33-
34-
# def emit_photo_data(a_photo):
35-
# result = []
36-
# result.append(f"<p>location: {a_photo['location']}</p>")
37-
# result.append(f"<p>date: {a_photo['date'].strftime('%Y-%m-%d')}</p>")
38-
# return "\n".join(result)

chapter08/tests/case03/test_case03.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
render_person,
55
render_photo,
66
photo_div,
7-
zznew,
7+
emit_photo_data,
88
# emit_photo_data,
99
)
1010

@@ -66,10 +66,13 @@ def test_emit_photo_data():
6666
}
6767

6868
# 함수 실행
69-
result = zznew(photo)
69+
result = emit_photo_data(photo)
7070

7171
# 결과 검증
72-
# assert "<p>title: 개인 사진</p>" in result
72+
assert "<p>title: 개인 사진</p>" in result
7373
assert "<p>location: 제주도</p>" in result
7474
assert "<p>date: 2023-12-25</p>" in result
75-
assert result == "<p>location: 제주도</p>\n<p>date: 2023-12-25</p>"
75+
assert (
76+
result
77+
== "<p>title: 개인 사진</p>\n<p>location: 제주도</p>\n<p>date: 2023-12-25</p>"
78+
)

0 commit comments

Comments
 (0)