File: test_clitoolbar.py

package info (click to toggle)
mycli 1.66.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,276 kB
  • sloc: python: 12,440; makefile: 10
file content (64 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download
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
58
59
60
61
62
63
64
# type: ignore

from prompt_toolkit.shortcuts import PromptSession

from mycli.clitoolbar import create_toolbar_tokens_func
from mycli.main import MyCli
from mycli.sqlexecute import SQLExecute
from test.utils import HOST, PASSWORD, PORT, USER, dbtest


@dbtest
def test_create_toolbar_tokens_func_initial():
    m = MyCli()
    m.sqlexecute = SQLExecute(
        None,
        USER,
        PASSWORD,
        HOST,
        PORT,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
    )
    m.prompt_app = PromptSession()
    iteration = 0
    f = create_toolbar_tokens_func(m, lambda: iteration == 0, m.toolbar_format)
    result = f()
    m.close()
    assert any("right-arrow accepts full-line suggestion" in token for token in result)


@dbtest
def test_create_toolbar_tokens_func_short():
    m = MyCli()
    m.sqlexecute = SQLExecute(
        None,
        USER,
        PASSWORD,
        HOST,
        PORT,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
    )
    m.prompt_app = PromptSession()
    iteration = 1
    f = create_toolbar_tokens_func(m, lambda: iteration == 0, m.toolbar_format)
    result = f()
    m.close()
    assert not any("right-arrow accepts full-line suggestion" in token for token in result)