def step_prepare_data(context): """Create table, insert a record.""" context.cli.sendline('drop table if exists a;') 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)
def step_see_db_dropped_no_default(context): """Wait to see drop database output.""" user = context.conf['user'] host = context.conf['host'] database = '(none)' context.currentdb = None wrappers.expect_exact(context, 'Query OK, 0 rows affected', timeout=2) wrappers.wait_prompt(context, '{0}@{1}:{2}>'.format(user, host, database))
def step_prepare_data(context): """Create table, insert a record.""" context.cli.sendline('drop table if exists a;') 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)
def step_ctrl_d(context): """ Send Ctrl + D to hopefully exit. """ # turn off pager before exiting context.cli.sendline("\pset pager off") wrappers.wait_prompt(context) context.cli.sendcontrol("d") context.cli.expect_exact(pexpect.EOF, timeout=15) context.exit_sent = True
def step_ctrl_d(context): """ Send Ctrl + D to hopefully exit. """ # turn off pager before exiting context.cli.sendline('\pset pager off') wrappers.wait_prompt(context) context.cli.sendcontrol('d') context.cli.expect_exact(pexpect.EOF, timeout=15) context.exit_sent = True
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)
def step_wait_prompt(context): wrappers.wait_prompt(context)
def step_see_prompt(context): """Wait to see the prompt.""" user = context.conf['user'] host = context.conf['host'] dbname = context.currentdb wrappers.wait_prompt(context, '{0}@{1}:{2}> '.format(user, host, dbname))
def step_set_expanded(context, mode): """Set expanded to mode.""" context.cli.sendline("\\" + f"x {mode}") wrappers.expect_exact(context, "Expanded display is", timeout=2) wrappers.wait_prompt(context)
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)
def step_wait_prompt(context): wrappers.wait_prompt(context)
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)
def step_see_error_message(context): wrappers.expect_exact(context, 'column "a" does not exist', timeout=2) wrappers.wait_prompt(context)