mirror of https://github.com/dbcli/pgcli
Test using behave the tee command
This commit is contained in:
parent
fb25e4b923
commit
5a60402649
|
@ -19,6 +19,7 @@ Internal changes:
|
|||
* Add pager wrapper for behave tests (Thanks: `Dick Marinus`_).
|
||||
* Behave quit pgcli nicely (Thanks: `Dick Marinus`_).
|
||||
* Behave test source command (Thanks: `Dick Marinus`_).
|
||||
* Test using behave the tee command (Thanks: `Dick Marinus`_).
|
||||
|
||||
1.5.1
|
||||
=====
|
||||
|
|
|
@ -8,3 +8,14 @@ Feature: I/O commands
|
|||
and we exit the editor
|
||||
then we see dbcli prompt
|
||||
and we see the sql in prompt
|
||||
|
||||
Scenario: tee output from query
|
||||
When we run dbcli
|
||||
and we wait for prompt
|
||||
and we tee output
|
||||
and we wait for prompt
|
||||
and we query "select 123456"
|
||||
and we wait for prompt
|
||||
and we notee output
|
||||
and we wait for prompt
|
||||
then we see 123456 in tee output
|
||||
|
|
|
@ -42,3 +42,40 @@ def step_edit_done_sql(context):
|
|||
# Cleanup the edited file.
|
||||
if context.editor_file_name and os.path.exists(context.editor_file_name):
|
||||
os.remove(context.editor_file_name)
|
||||
|
||||
|
||||
@when(u'we tee output')
|
||||
def step_tee_ouptut(context):
|
||||
context.tee_file_name = [
|
||||
'..',
|
||||
'tee_file_{0}.sql'.format(context.conf['vi'])
|
||||
]
|
||||
if os.path.exists(os.path.join(*context.tee_file_name)):
|
||||
os.remove(os.path.join(*context.tee_file_name))
|
||||
context.cli.sendline('\o {0}'.format(context.tee_file_name[1]))
|
||||
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)
|
||||
|
||||
|
||||
@when(u'we query "select 123456"')
|
||||
def step_query_select_123456(context):
|
||||
context.cli.sendline('select 123456')
|
||||
|
||||
|
||||
@when(u'we notee output')
|
||||
def step_notee_output(context):
|
||||
context.cli.sendline('notee')
|
||||
wrappers.expect_exact(context, "Time", timeout=5)
|
||||
|
||||
|
||||
@then(u'we see 123456 in tee output')
|
||||
def step_see_123456_in_ouput(context):
|
||||
with open(os.path.join(*context.tee_file_name)) as f:
|
||||
assert '123456' in f.read()
|
||||
if os.path.exists(os.path.join(*context.tee_file_name)):
|
||||
os.remove(os.path.join(*context.tee_file_name))
|
||||
context.atprompt = True
|
||||
|
|
Loading…
Reference in New Issue