summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2017-06-26 11:28:32 -0700
committerIrina Truong <i.chernyavska@gmail.com>2017-06-26 11:28:32 -0700
commit8353f1ef2dba2fc83a0b614d30c29ab9b7db7be6 (patch)
tree4490b4c1b761703ff877504591e755f5dc38b790
parent018f495f10c1e07191819a2cf11232a9b3f61327 (diff)
Added functional tests for expanded mode.
-rw-r--r--tests/features/expanded.feature26
-rw-r--r--tests/features/steps/expanded.py65
2 files changed, 91 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..690c0a2b
--- /dev/null
+++ b/tests/features/steps/expanded.py
@@ -0,0 +1,65 @@
+# -*- 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)