File: auto_vertical.py

package info (click to toggle)
mycli 1.42.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,036 kB
  • sloc: python: 8,587; makefile: 10
file content (55 lines) | stat: -rw-r--r-- 1,412 bytes parent folder | download | duplicates (2)
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
# type: ignore

from textwrap import dedent

from behave import then, when
from utils import parse_cli_args_to_dict
import wrappers


@when("we run dbcli with {arg}")
def step_run_cli_with_arg(context, arg):
    wrappers.run_cli(context, run_args=parse_cli_args_to_dict(arg))


@when("we execute a small query")
def step_execute_small_query(context):
    context.cli.sendline("select 1")


@when("we execute a large query")
def step_execute_large_query(context):
    context.cli.sendline(f"select {','.join([str(n) for n in range(1, 50)])}")


@then("we see small results in horizontal format")
def step_see_small_results(context):
    expected = (
        dedent(
            """
            +---+\r
            | 1 |\r
            +---+\r
            | 1 |\r
            +---+
            """
        ).strip()
        + '\r\n\r\n'
    )

    wrappers.expect_pager(
        context,
        expected,
        timeout=5,
    )
    wrappers.expect_exact(context, "1 row in set", timeout=2)


@then("we see large results in vertical format")
def step_see_large_results(context):
    rows = [f"{str(n):3}| {n}" for n in range(1, 50)]
    delimited_rows = '\r\n'.join(rows) + '\r\n'
    expected = "***************************[ 1. row ]***************************\r\n" + delimited_rows + "\r\n"

    wrappers.expect_pager(context, expected, timeout=10)
    wrappers.expect_exact(context, "1 row in set", timeout=2)