Add tests for app/print_table.py

This commit is contained in:
Luke Tainton 2022-07-10 18:15:04 +01:00
parent 20c5357672
commit 3b208c4d32
No known key found for this signature in database
GPG Key ID: ABEE10849773E353
2 changed files with 20 additions and 1 deletions

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"