From 3b208c4d325e5741df6d799f0a1edec6676662c1 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sun, 10 Jul 2022 18:15:04 +0100 Subject: [PATCH] Add tests for app/print_table.py --- app/print_table.py | 2 +- tests/test_print_table.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/test_print_table.py diff --git a/app/print_table.py b/app/print_table.py index a4626f9..cbb8a74 100644 --- a/app/print_table.py +++ b/app/print_table.py @@ -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)) diff --git a/tests/test_print_table.py b/tests/test_print_table.py new file mode 100644 index 0000000..7610486 --- /dev/null +++ b/tests/test_print_table.py @@ -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"