diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-30 08:13:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 10:48:06 +0000 |
commit | 57bc0d56d7e741e1e99d96f14e7ab93232440a16 (patch) | |
tree | 0d4631d7416ba98b7a414dc825419afd5b177be0 /tests/tabular_output/test_vertical_table_adapter.py | |
parent | Initial commit. (diff) | |
download | cli-helpers-57bc0d56d7e741e1e99d96f14e7ab93232440a16.tar.xz cli-helpers-57bc0d56d7e741e1e99d96f14e7ab93232440a16.zip |
Adding upstream version 2.1.0.upstream/2.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/tabular_output/test_vertical_table_adapter.py')
-rw-r--r-- | tests/tabular_output/test_vertical_table_adapter.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/tabular_output/test_vertical_table_adapter.py b/tests/tabular_output/test_vertical_table_adapter.py new file mode 100644 index 0000000..8b5e18c --- /dev/null +++ b/tests/tabular_output/test_vertical_table_adapter.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +"""Test the vertical table formatter.""" + +from textwrap import dedent + +from cli_helpers.compat import text_type +from cli_helpers.tabular_output import vertical_table_adapter + + +def test_vertical_table(): + """Test the default settings for vertical_table().""" + results = [('hello', text_type(123)), ('world', text_type(456))] + + expected = dedent("""\ + ***************************[ 1. row ]*************************** + name | hello + age | 123 + ***************************[ 2. row ]*************************** + name | world + age | 456""") + assert expected == "\n".join( + vertical_table_adapter.adapter(results, ('name', 'age'))) + + +def test_vertical_table_customized(): + """Test customized settings for vertical_table().""" + results = [('john', text_type(47)), ('jill', text_type(50))] + + expected = dedent("""\ + -[ PERSON 1 ]----- + name | john + age | 47 + -[ PERSON 2 ]----- + name | jill + age | 50""") + assert expected == "\n".join(vertical_table_adapter.adapter( + results, ('name', 'age'), sep_title='PERSON {n}', + sep_character='-', sep_length=(1, 5))) |