Ejemplo n.º 1
0
def test_format_output_auto_expand():
    table_results = format_output('Title', [('abc', 'def')],
                                  ['head1', 'head2'], 'test status', 'psql',
                                  max_width=100)
    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',
                                     max_width=1)
    expanded = ['Title', u'***************************[ 1. row ]***************************\nhead1 | abc\nhead2 | def\n', 'test status']
    assert expanded_results == expanded
Ejemplo n.º 2
0
def run(executor, sql, join=False):
    " Return string output for the sql to be run "
    result = []
    for title, rows, headers, status in executor.run(sql):
        result.extend(format_output(title, rows, headers, status, 'psql'))
    if join:
        result = '\n'.join(result)
    return result
Ejemplo n.º 3
0
def run(executor, sql, join=False):
    " Return string output for the sql to be run "
    result = []
    for title, rows, headers, status in executor.run(sql):
        result.extend(format_output(title, rows, headers, status, 'psql', special.is_expanded_output()))
    if join:
        result = '\n'.join(result)
    return result
Ejemplo n.º 4
0
def test_format_output():
    results = format_output('Title', [('abc', 'def')], ['head1', 'head2'],
                            'test status', 'psql')
    expected = [
        'Title',
        '+---------+---------+\n| head1   | head2   |\n|---------+---------|\n| abc     | def     |\n+---------+---------+',
        'test status'
    ]
    assert results == expected
Ejemplo n.º 5
0
def test_format_output_no_table():
    results = format_output('Title', [('abc', 'def')], ['head1', 'head2'],
                            'test status', None)
    expected = ['Title', 'head1\thead2', 'abc\tdef', 'test status']
    assert results == expected
Ejemplo n.º 6
0
def test_format_output():
    results = format_output('Title', [('abc', 'def')], ['head1', 'head2'],
                            'test status', 'psql')
    expected = ['Title', '+---------+---------+\n| head1   | head2   |\n|---------+---------|\n| abc     | def     |\n+---------+---------+', 'test status']
    assert results == expected