Пример #1
0
def step_see_db_connected(context):
    """
    Wait to see drop database output.
    """
    wrappers.expect_exact(context,
                          'You are now connected to database',
                          timeout=2)
Пример #2
0
def step_send_source_command(context):
    context.tmpfile_sql_help = tempfile.NamedTemporaryFile(prefix='pgcli_')
    context.tmpfile_sql_help.write(b'\?')
    context.tmpfile_sql_help.flush()
    context.cli.sendline('\i {0}'.format(context.tmpfile_sql_help.name))
    wrappers.expect_exact(
        context, context.conf['pager_boundary'] + '\r\n', timeout=5)
Пример #3
0
def step_see_prompt(context):
    """
    Wait to see the prompt.
    """
    wrappers.expect_exact(context,
                          '{0}> '.format(context.conf['dbname']),
                          timeout=5)
    context.atprompt = True
Пример #4
0
def step_edit_done_sql(context):
    for match in 'select * from abc'.split(' '):
        wrappers.expect_exact(context, match, timeout=1)
    # Cleanup the command line.
    context.cli.sendcontrol('c')
    # Cleanup the edited file.
    if context.editor_file_name and os.path.exists(context.editor_file_name):
        os.remove(context.editor_file_name)
Пример #5
0
def step_see_found(context):
    wrappers.expect_exact(
        context,
        context.conf['pager_boundary'] + '\r' + dedent('''
            +------------+\r
            | ?column?   |\r
            |------------|\r
            | found      |\r
            +------------+\r
            SELECT 1\r
        ''') + context.conf['pager_boundary'],
        timeout=5
    )
Пример #6
0
def step_prepare_data(context):
    """Create table, insert a record."""
    context.cli.sendline('drop table if exists a;')
    wrappers.expect_exact(
        context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
    context.cli.sendline('y')

    wrappers.wait_prompt(context)
    context.cli.sendline(
        'create table a(x integer, y real, z numeric(10, 4));')
    wrappers.expect_pager(context, 'CREATE TABLE\r\n', timeout=2)
    context.cli.sendline('''insert into a(x, y, z) values(1, 1.0, 1.0);''')
    wrappers.expect_pager(context, 'INSERT 0 1\r\n', timeout=2)
Пример #7
0
def step_edit_file(context):
    """Edit file with external editor."""
    context.editor_file_name = os.path.join(
        context.package_root, 'test_file_{0}.sql'.format(context.conf['vi']))
    if os.path.exists(context.editor_file_name):
        os.remove(context.editor_file_name)
    context.cli.sendline('\e {0}'.format(
        os.path.basename(context.editor_file_name)))
    wrappers.expect_exact(
        context,
        'Entering Ex mode.  Type "visual" to go to Normal mode.',
        timeout=2)
    wrappers.expect_exact(context, ':', timeout=2)
Пример #8
0
def step_tee_ouptut(context):
    context.tee_file_name = os.path.join(
        context.package_root, 'tee_file_{0}.sql'.format(context.conf['vi']))
    if os.path.exists(context.tee_file_name):
        os.remove(context.tee_file_name)
    context.cli.sendline('\o {0}'.format(
        os.path.basename(context.tee_file_name)))
    wrappers.expect_exact(context,
                          context.conf['pager_boundary'] + '\r\n',
                          timeout=5)
    wrappers.expect_exact(context, "Writing to file", timeout=5)
    wrappers.expect_exact(context,
                          context.conf['pager_boundary'] + '\r\n',
                          timeout=5)
    wrappers.expect_exact(context, "Time", timeout=5)
Пример #9
0
def step_see_help(context):
    for expected_line in context.fixture_data['help_commands.txt']:
        wrappers.expect_exact(context, expected_line, timeout=1)
Пример #10
0
def step_wait_exit(context):
    """
    Make sure the cli exits.
    """
    wrappers.expect_exact(context, pexpect.EOF, timeout=5)
Пример #11
0
def step_see_named_query_executed(context):
    """
    Wait to see select output.
    """
    wrappers.expect_exact(context, '12345', timeout=1)
    wrappers.expect_exact(context, 'SELECT 1', timeout=1)
Пример #12
0
def step_confirm_destructive_command(context):
    """Confirm destructive command."""
    wrappers.expect_exact(
        context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
    context.cli.sendline('y')
Пример #13
0
def step_set_expanded(context, mode):
    """Set expanded to mode."""
    context.cli.sendline('\\' + 'x {}'.format(mode))
    wrappers.expect_exact(context, 'Expanded display is', timeout=2)
    wrappers.wait_prompt(context)
Пример #14
0
def step_notee_output(context):
    context.cli.sendline('\o')
    wrappers.expect_exact(context, "Time", timeout=5)
Пример #15
0
def step_edit_quit(context):
    context.cli.sendline('x')
    wrappers.expect_exact(context, "written", timeout=2)
Пример #16
0
def step_edit_type_sql(context):
    context.cli.sendline('i')
    context.cli.sendline('select * from abc')
    context.cli.sendline('.')
    wrappers.expect_exact(context, ':', timeout=2)