Skip to content

Commit c8b274a

Browse files
committed
Added value error tests
1 parent 37256fe commit c8b274a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

Diff for: tests/test_convert.py

+57
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,60 @@ def test_footer():
107107
"╚═════╩═══════════════════════╝\n"
108108
)
109109
assert text == expected
110+
111+
112+
def test_header_footer_unequal():
113+
with pytest.raises(ValueError):
114+
t2a(
115+
header=["H", "R", "S"],
116+
footer=["SUM", "130", "140", "135", "130"],
117+
)
118+
119+
120+
def test_header_body_unequal():
121+
with pytest.raises(ValueError):
122+
t2a(
123+
header=["#", "G", "H", "R", "S"],
124+
body=[
125+
["0", "45", "30", "32", "28"],
126+
["1", "30", "40", "35", "30", "36"],
127+
["2", "30", "40", "35", "30"],
128+
],
129+
)
130+
131+
132+
def test_footer_body_unequal():
133+
with pytest.raises(ValueError):
134+
t2a(
135+
body=[
136+
["0", "45", "30", "32", "28"],
137+
["1", "30", "40", "35", "30"],
138+
["2", "30", "40", "35", "30"],
139+
],
140+
footer=["SUM", "130", "140", "135", "130", "36"],
141+
)
142+
143+
144+
def test_empty_header():
145+
text = t2a(
146+
header=[],
147+
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
148+
)
149+
expected = (
150+
"╔═══╦═══════════════════╗\n"
151+
"║ 1 ║ 30 40 35 30 ║\n"
152+
"║ 2 ║ 30 40 35 30 ║\n"
153+
"╚═══╩═══════════════════╝\n"
154+
)
155+
assert text == expected
156+
157+
158+
def test_empty_body():
159+
text = t2a(header=["#", "G", "H", "R", "S"], body=[])
160+
expected = (
161+
"╔═══╦═══════════════╗\n"
162+
"║ # ║ G H R S ║\n"
163+
"╟───╫───────────────╢\n"
164+
"╚═══╩═══════════════╝\n"
165+
)
166+
assert text == expected

0 commit comments

Comments
 (0)