summaryrefslogtreecommitdiffstats
path: root/tests/features/steps/named_queries.py
blob: 3f52859b03cb17eb1949fb5f9a99aafb67c40dac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
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 behave import when, then
import wrappers


@when("we save a named query")
def step_save_named_query(context):
    """
    Send \ns command
    """
    context.cli.sendline("\\ns foo SELECT 12345")


@when("we use a named query")
def step_use_named_query(context):
    """
    Send \n command
    """
    context.cli.sendline("\\n foo")


@when("we delete a named query")
def step_delete_named_query(context):
    """
    Send \nd command
    """
    context.cli.sendline("\\nd foo")


@then("we see the named query saved")
def step_see_named_query_saved(context):
    """
    Wait to see query saved.
    """
    wrappers.expect_exact(context, "Saved.", timeout=2)


@then("we see the named query executed")
def step_see_named_query_executed(context):
    """
    Wait to see select output.
    """
    wrappers.expect_exact(context, "12345", timeout=1)
    wrappers.expect_exact(context, "SELECT 1", timeout=1)


@then("we see the named query deleted")
def step_see_named_query_deleted(context):
    """
    Wait to see query deleted.
    """
    wrappers.expect_pager(context, "foo: Deleted\r\n", timeout=1)