summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2017-04-28 23:28:50 -0700
committerGitHub <noreply@github.com>2017-04-28 23:28:50 -0700
commite4d75fcfb6901af25f51261085a3da6ea770553e (patch)
tree1855b3c59d6afccaa7d015c9ec7bfc6d610949e9
parent2c89329b93fe02f94b9bb8a6c39c1d8243a6a9a0 (diff)
parent8fa3d18353f4fe87af5d0e9e90bcde1fc20b81aa (diff)
Merge pull request #699 from dbcli/feature/behave_source_command
behave test source command
-rw-r--r--changelog.rst1
-rw-r--r--tests/features/basic_commands.feature6
-rw-r--r--tests/features/steps/basic_commands.py12
3 files changed, 19 insertions, 0 deletions
diff --git a/changelog.rst b/changelog.rst
index eb68b0db..2f0ebe2e 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -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
=====
diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature
index 227fe769..025b5850 100644
--- a/tests/features/basic_commands.feature
+++ b/tests/features/basic_commands.feature
@@ -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
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index 4da023d2..5a30e6cf 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -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)