summaryrefslogtreecommitdiffstats
path: root/tests/test_main.py
diff options
context:
space:
mode:
authorJoakim Koljonen <koljonen@outlook.com>2017-01-16 13:27:19 +0900
committerJoakim Koljonen <koljonen@outlook.com>2017-03-16 03:06:56 +0100
commit9a8d2c2d6f5acf6ad37b84ebc59e8a95e294349a (patch)
tree8a9d0b9f85fcd61971b90c3e450f05152370dc83 /tests/test_main.py
parentd32049bfdefe0af6dd49a295e1e24b813f9781d2 (diff)
Make format_output take a settings object
Diffstat (limited to 'tests/test_main.py')
-rw-r--r--tests/test_main.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_main.py b/tests/test_main.py
index e461fc0d..b705b730 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -8,7 +8,9 @@ try:
except ImportError:
setproctitle = None
-from pgcli.main import obfuscate_process_password, format_output, PGCli
+from pgcli.main import (
+ obfuscate_process_password, format_output, PGCli, OutputSettings
+)
from utils import dbtest, run
@@ -47,21 +49,20 @@ def test_obfuscate_process_password():
def test_format_output():
+ settings = OutputSettings(table_format='psql', dcmlfmt='d', floatfmt='g')
results = format_output('Title', [('abc', 'def')], ['head1', 'head2'],
- 'test status', 'psql', dcmlfmt='d', floatfmt='g',)
+ 'test status', settings)
expected = ['Title', '+---------+---------+\n| head1 | head2 |\n|---------+---------|\n| abc | def |\n+---------+---------+', 'test status']
assert results == expected
def test_format_output_auto_expand():
+ settings = OutputSettings(table_format='psql', dcmlfmt='d', floatfmt='g', max_width=100)
table_results = format_output('Title', [('abc', 'def')],
- ['head1', 'head2'], 'test status', 'psql', dcmlfmt='d', floatfmt='g',
- max_width=100)
+ ['head1', 'head2'], 'test status', settings)
table = ['Title', '+---------+---------+\n| head1 | head2 |\n|---------+---------|\n| abc | def |\n+---------+---------+', 'test status']
assert table_results == table
-
expanded_results = format_output('Title', [('abc', 'def')],
- ['head1', 'head2'], 'test status', 'psql', dcmlfmt='d', floatfmt='g',
- max_width=1)
+ ['head1', 'head2'], 'test status', settings._replace(max_width=1))
expanded = ['Title', u'-[ RECORD 0 ]-------------------------\nhead1 | abc\nhead2 | def\n', 'test status']
assert expanded_results == expanded