summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roten <tsroten@users.noreply.github.com>2017-06-26 15:18:45 -0500
committerGitHub <noreply@github.com>2017-06-26 15:18:45 -0500
commit0ea4c177c559ab467848af2af398bd66d46dfe95 (patch)
tree1e66561499859af6f675ed5857c40fc333a9cc0b
parent018f495f10c1e07191819a2cf11232a9b3f61327 (diff)
parent25dd0360d07fcefaad2d492b700c3a32c5d72c92 (diff)
Merge pull request #740 from dbcli/j-bennet/behave-tests-expanded
Added functional tests for expanded mode.
-rw-r--r--tests/features/expanded.feature26
-rw-r--r--tests/features/steps/expanded.py61
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/features/expanded.feature b/tests/features/expanded.feature
new file mode 100644
index 00000000..e92f1d00
--- /dev/null
+++ b/tests/features/expanded.feature
@@ -0,0 +1,26 @@
+Feature: expanded mode:
+ on, off, auto
+
+ Scenario: expanded on
+ When we prepare the test data
+ and we set expanded on
+ and we select from table
+ then we see expanded data selected
+ when we drop table
+ then we see table dropped
+
+ Scenario: expanded off
+ When we prepare the test data
+ and we set expanded off
+ and we select from table
+ then we see nonexpanded data selected
+ when we drop table
+ then we see table dropped
+
+ Scenario: expanded auto
+ When we prepare the test data
+ and we set expanded auto
+ and we select from table
+ then we see auto data selected
+ when we drop table
+ then we see table dropped
diff --git a/tests/features/steps/expanded.py b/tests/features/steps/expanded.py
new file mode 100644
index 00000000..31622edf
--- /dev/null
+++ b/tests/features/steps/expanded.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8
+"""Steps for behavioral style tests are defined in this module.
+
+Each step is defined by the string decorating it. This string is used
+to call the step in "*.feature" file.
+
+"""
+from __future__ import unicode_literals
+
+import wrappers
+from behave import when, then
+from textwrap import dedent
+
+
+@when('we prepare the test data')
+def step_prepare_data(context):
+ """Create table, insert a record."""
+ context.cli.sendline('drop table if exists a;')
+ wrappers.wait_prompt(context)
+ context.cli.sendline(
+ 'create table a(x integer, y real, z numeric(10, 4));')
+ wrappers.expect_pager(context, 'CREATE TABLE\r\n', timeout=2)
+ context.cli.sendline('''insert into a(x, y, z) values(1, 1.0, 1.0);''')
+ wrappers.expect_pager(context, 'INSERT 0 1\r\n', timeout=2)
+
+
+@when('we set expanded {mode}')
+def step_set_expanded(context, mode):
+ """Set expanded to mode."""
+ context.cli.sendline('\\' + 'x {}'.format(mode))
+ wrappers.expect_exact(context, 'Expanded display is', timeout=2)
+ wrappers.wait_prompt(context)
+
+
+@then('we see {which} data selected')
+def step_see_data(context, which):
+ """Select data from expanded test table."""
+ if which == 'expanded':
+ wrappers.expect_pager(
+ context,
+ dedent('''\
+ -[ RECORD 1 ]-------------------------\r
+ x | 1\r
+ y | 1.0\r
+ z | 1.0000\r
+ \r
+ SELECT 1\r
+ '''),
+ timeout=1)
+ else:
+ wrappers.expect_pager(
+ context,
+ dedent('''\
+ +-----+-----+--------+\r
+ | x | y | z |\r
+ |-----+-----+--------|\r
+ | 1 | 1.0 | 1.0000 |\r
+ +-----+-----+--------+\r
+ SELECT 1\r
+ '''),
+ timeout=1)