summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2019-05-21 20:21:58 -0700
committerIrina Truong <i.chernyavska@gmail.com>2019-05-21 20:21:58 -0700
commitb4fbe28286410f6b61bd8b9d4a06c2dbfc295bb9 (patch)
tree2a064f026129acd6baa7dd7754ab1fae07b0f761
parent5177c9922ebb62ca0b90307c38a13ddc8a574d24 (diff)
Fix for dsn_password behave test.
-rw-r--r--tests/features/basic_commands.feature6
-rw-r--r--tests/features/fixture_data/mock_pg_service.conf1
-rw-r--r--tests/features/specials.feature1
-rw-r--r--tests/features/steps/basic_commands.py10
-rw-r--r--tests/features/steps/crud_database.py3
-rw-r--r--tests/features/steps/wrappers.py4
6 files changed, 16 insertions, 9 deletions
diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature
index 29e920f2..1f63a8ad 100644
--- a/tests/features/basic_commands.feature
+++ b/tests/features/basic_commands.feature
@@ -44,8 +44,10 @@ Feature: run the cli,
when we send "\?" command
then we see help output
+ @wip
Scenario: run the cli with dsn and password
When we launch dbcli using dsn_password
then we send password
- When we send "\?" command
- then we see help output
+ and we see dbcli prompt
+ when we send "\?" command
+ then we see help output
diff --git a/tests/features/fixture_data/mock_pg_service.conf b/tests/features/fixture_data/mock_pg_service.conf
index 1c10ee34..15f98113 100644
--- a/tests/features/fixture_data/mock_pg_service.conf
+++ b/tests/features/fixture_data/mock_pg_service.conf
@@ -1,3 +1,4 @@
[mock_postgres]
dbname=postgres
host=localhost
+user=postgres
diff --git a/tests/features/specials.feature b/tests/features/specials.feature
index bb367578..63c5cdc9 100644
--- a/tests/features/specials.feature
+++ b/tests/features/specials.feature
@@ -1,6 +1,5 @@
Feature: Special commands
- @wip
Scenario: run refresh command
When we refresh completions
and we wait for prompt
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index 0d193f3c..fcb250c7 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -6,7 +6,6 @@ This string is used to call the step in "*.feature" file.
"""
from __future__ import unicode_literals, print_function
-import sys
import pexpect
import subprocess
import tempfile
@@ -33,9 +32,11 @@ def step_see_list_databases(context):
def step_run_cli(context):
wrappers.run_cli(context)
+
@when('we launch dbcli using {arg}')
def step_run_cli_using_arg(context, arg):
prompt_check = False
+ currentdb = None
if arg == '--username':
arg = '--username={}'.format(context.conf['user'])
if arg == '--user':
@@ -48,7 +49,9 @@ def step_run_cli_using_arg(context, arg):
if arg == 'dsn_password': # This uses the mock_pg_service.conf file in fixtures folder.
arg = 'service=mock_postgres --password'
prompt_check = False
- wrappers.run_cli(context, run_args=[arg], prompt_check=prompt_check)
+ currentdb = "postgres"
+ wrappers.run_cli(context, run_args=[arg], prompt_check=prompt_check, currentdb=currentdb)
+
@when('we wait for prompt')
def step_wait_prompt(context):
@@ -116,7 +119,8 @@ def step_confirm_destructive_command(context):
context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
context.cli.sendline('y')
+
@then(u'we send password')
def step_send_password(context):
- wrappers.expect_exact(context, 'Password for postgres:', timeout=5)
+ wrappers.expect_exact(context, 'Password for', timeout=5)
context.cli.sendline(context.conf['pass'] or 'DOES NOT MATTER')
diff --git a/tests/features/steps/crud_database.py b/tests/features/steps/crud_database.py
index 0a0928fc..3ec27c96 100644
--- a/tests/features/steps/crud_database.py
+++ b/tests/features/steps/crud_database.py
@@ -65,7 +65,8 @@ def step_see_prompt(context):
"""
Wait to see the prompt.
"""
- wrappers.expect_exact(context, '{0}> '.format(context.conf['dbname']), timeout=5)
+ db_name = getattr(context, "currentdb", context.conf['dbname'])
+ wrappers.expect_exact(context, '{0}> '.format(db_name), timeout=5)
context.atprompt = True
diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py
index 11809b30..23f9cc2b 100644
--- a/tests/features/steps/wrappers.py
+++ b/tests/features/steps/wrappers.py
@@ -49,7 +49,7 @@ def expect_pager(context, expected, timeout):
context.conf['pager_boundary'], expected), timeout=timeout)
-def run_cli(context, run_args=None, prompt_check=True):
+def run_cli(context, run_args=None, prompt_check=True, currentdb=None):
"""Run the process using pexpect."""
run_args = run_args or []
cli_cmd = context.conf.get('cli_command')
@@ -59,7 +59,7 @@ def run_cli(context, run_args=None, prompt_check=True):
context.logfile = StringIO()
context.cli.logfile = context.logfile
context.exit_sent = False
- context.currentdb = context.conf['dbname']
+ context.currentdb = currentdb or context.conf['dbname']
context.cli.sendline('\pset pager always')
if prompt_check:
wait_prompt(context)