summaryrefslogtreecommitdiffstats
path: root/tests/features
diff options
context:
space:
mode:
authorDick Marinus <dick@mrns.nl>2017-04-25 07:37:53 +0200
committerDick Marinus <dick@mrns.nl>2017-04-25 07:37:53 +0200
commitbc47a07d92d3067ee0e943a8fcec0222f51378d0 (patch)
treef56a541140dee320cbd67d358d79c9db1bdd9d6a /tests/features
parent1e1d980ae2967a9fee14dfeb13a63cbe34769fd5 (diff)
behave pager wrapper
Diffstat (limited to 'tests/features')
-rw-r--r--tests/features/environment.py7
-rw-r--r--tests/features/steps/crud_table.py24
-rw-r--r--tests/features/steps/named_queries.py4
-rw-r--r--tests/features/steps/specials.py3
-rw-r--r--tests/features/steps/wrappers.py5
-rwxr-xr-xtests/features/wrappager.py16
6 files changed, 48 insertions, 11 deletions
diff --git a/tests/features/environment.py b/tests/features/environment.py
index 51ae86b5..aa1f90bf 100644
--- a/tests/features/environment.py
+++ b/tests/features/environment.py
@@ -34,8 +34,13 @@ def before_all(context):
'vi': vi,
'cli_command': context.config.userdata.get('pg_cli_command', None) or
sys.executable +
- ' -c "import coverage; coverage.process_startup(); import pgcli.main; pgcli.main.cli()"'
+ ' -c "import coverage; coverage.process_startup(); import pgcli.main; pgcli.main.cli()"',
+ 'pager_boundary': '---boundary---',
}
+ os.environ['PAGER'] = "{0} {1} {2}".format(
+ sys.executable, "tests/features/wrappager.py",
+ context.conf['pager_boundary']
+ )
# Store old env vars.
context.pgenv = {
diff --git a/tests/features/steps/crud_table.py b/tests/features/steps/crud_table.py
index 0863a224..360f78f9 100644
--- a/tests/features/steps/crud_table.py
+++ b/tests/features/steps/crud_table.py
@@ -8,6 +8,7 @@ from __future__ import unicode_literals
import wrappers
from behave import when, then
+from textwrap import dedent
@when('we create table')
@@ -63,7 +64,7 @@ def step_see_table_created(context):
"""
Wait to see create table output.
"""
- wrappers.expect_exact(context, 'CREATE TABLE', timeout=2)
+ wrappers.expect_pager(context, 'CREATE TABLE\r\n', timeout=2)
@then('we see record inserted')
@@ -71,7 +72,7 @@ def step_see_record_inserted(context):
"""
Wait to see insert output.
"""
- wrappers.expect_exact(context, 'INSERT 0 1', timeout=2)
+ wrappers.expect_pager(context, 'INSERT 0 1\r\n', timeout=2)
@then('we see record updated')
@@ -79,7 +80,7 @@ def step_see_record_updated(context):
"""
Wait to see update output.
"""
- wrappers.expect_exact(context, 'UPDATE 1', timeout=2)
+ wrappers.expect_pager(context, 'UPDATE 1\r\n', timeout=2)
@then('we see data selected')
@@ -87,8 +88,17 @@ def step_see_data_selected(context):
"""
Wait to see select output.
"""
- wrappers.expect_exact(context, 'yyy', timeout=1)
- wrappers.expect_exact(context, 'SELECT 1', timeout=1)
+ wrappers.expect_pager(
+ context,
+ dedent('''\
+ +-----+\r
+ | x |\r
+ |-----|\r
+ | yyy |\r
+ +-----+\r
+ SELECT 1\r
+ '''),
+ timeout=1)
@then('we see record deleted')
@@ -96,7 +106,7 @@ def step_see_data_deleted(context):
"""
Wait to see delete output.
"""
- wrappers.expect_exact(context, 'DELETE 1', timeout=2)
+ wrappers.expect_pager(context, 'DELETE 1\r\n', timeout=2)
@then('we see table dropped')
@@ -104,4 +114,4 @@ def step_see_table_dropped(context):
"""
Wait to see drop output.
"""
- wrappers.expect_exact(context, 'DROP TABLE', timeout=2)
+ wrappers.expect_pager(context, 'DROP TABLE\r\n', timeout=2)
diff --git a/tests/features/steps/named_queries.py b/tests/features/steps/named_queries.py
index cd1273c2..8f3c6d6d 100644
--- a/tests/features/steps/named_queries.py
+++ b/tests/features/steps/named_queries.py
@@ -39,7 +39,7 @@ def step_see_named_query_saved(context):
"""
Wait to see query saved.
"""
- wrappers.expect_exact(context, 'Saved.', timeout=1)
+ wrappers.expect_pager(context, 'Saved.\r\n', timeout=1)
@then('we see the named query executed')
@@ -56,4 +56,4 @@ def step_see_named_query_deleted(context):
"""
Wait to see query deleted.
"""
- wrappers.expect_exact(context, 'foo: Deleted', timeout=1)
+ wrappers.expect_pager(context, 'foo: Deleted\r\n', timeout=1)
diff --git a/tests/features/steps/specials.py b/tests/features/steps/specials.py
index a5122c22..851adeb7 100644
--- a/tests/features/steps/specials.py
+++ b/tests/features/steps/specials.py
@@ -23,4 +23,5 @@ def step_see_refresh_started(context):
"""
Wait to see refresh output.
"""
- wrappers.expect_exact(context, 'refresh started in the background', timeout=2)
+ wrappers.expect_pager(
+ context, 'Auto-completion refresh started in the background.\r\n', timeout=2)
diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py
index eac7c830..5e3b22f1 100644
--- a/tests/features/steps/wrappers.py
+++ b/tests/features/steps/wrappers.py
@@ -13,3 +13,8 @@ def expect_exact(context, expected, timeout):
raise Exception('Expected:\n---\n{0!r}\n---\n\nActual:\n---\n{1!r}\n---'.format(
expected,
actual))
+
+
+def expect_pager(context, expected, timeout):
+ expect_exact(context, "{0}\r\n{1}{0}\r\n".format(
+ context.conf['pager_boundary'], expected), timeout=timeout)
diff --git a/tests/features/wrappager.py b/tests/features/wrappager.py
new file mode 100755
index 00000000..51d49095
--- /dev/null
+++ b/tests/features/wrappager.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+import sys
+
+
+def wrappager(boundary):
+ print(boundary)
+ while 1:
+ buf = sys.stdin.read(2048)
+ if not buf:
+ break
+ sys.stdout.write(buf)
+ print(boundary)
+
+
+if __name__ == "__main__":
+ wrappager(sys.argv[1])