Add tests for app/print_table.py #15

Merged
luketainton merged 3 commits from unittest into main 2022-07-10 19:29:56 +02:00
2 changed files with 20 additions and 1 deletions
Showing only changes of commit 3b208c4d32 - Show all commits

View File

@ -18,6 +18,6 @@ def generate_prefix_string(prefixes: list) -> Union[str, None]:
return None
def print_table(table_data) -> None:
def print_table(table_data) -> None: # pragma: no cover
"""Print table generated by tabulate."""
print(tabulate(table_data))

19
tests/test_print_table.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""MODULE: Provides test cases for app/print_table.py."""
from app.print_table import generate_prefix_string # pragma: no cover
def test_generate_prefix_string_small() -> None:
"""TEST: Verifies if a small prefix list results in one line."""
test_query = ["abc", "def"]
result = generate_prefix_string(prefixes=test_query)
assert result == "abc, def\n"
def test_generate_prefix_string_large() -> None:
"""TEST: Verifies if a large prefix list results in multiple lines."""
test_query = ["abc", "def", "ghi", "jkl", "mno", "pqr"]
result = generate_prefix_string(prefixes=test_query)
assert result == "abc, def, ghi, jkl\nmno, pqr\n"