1
0
Fork 0

behave test source command

This commit is contained in:
Dick Marinus 2017-04-28 21:16:11 +02:00
parent 7eef21e3d3
commit 8fa3d18353
3 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,7 @@ Internal changes:
* Run pep8 checks in travis (Thanks: `Irina Truong`_).
* Add pager wrapper for behave tests (Thanks: `Dick Marinus`_).
* Behave quit pgcli nicely (Thanks: `Dick Marinus`_).
* Behave test source command (Thanks: `Dick Marinus`_).
1.5.1
=====

View File

@ -12,6 +12,12 @@ Feature: run the cli,
and we send "\?" command
then we see help output
Scenario: run source command
When we run dbcli
and we wait for prompt
and we send source command
then we see help output
Scenario: run the cli and exit
When we run dbcli
and we wait for prompt

View File

@ -7,6 +7,7 @@ This string is used to call the step in "*.feature" file.
from __future__ import unicode_literals
import pexpect
import tempfile
from behave import when
import wrappers
@ -19,6 +20,7 @@ def step_run_cli(context):
"""
cli_cmd = context.conf.get('cli_command')
context.cli = pexpect.spawnu(cli_cmd, cwd='..')
context.cli.logfile = open('/tmp/dmtest', 'a')
context.exit_sent = False
context.currentdb = context.conf['dbname']
@ -46,3 +48,13 @@ def step_send_help(context):
Send \? to see help.
"""
context.cli.sendline('\?')
@when(u'we send source command')
def step_send_source_command(context):
with tempfile.NamedTemporaryFile() as f:
f.write(b'\?')
f.flush()
context.cli.sendline('\i {0}'.format(f.name))
wrappers.expect_exact(
context, context.conf['pager_boundary'] + '\r\n', timeout=5)