blob: 8d9a87a557fd5112de8654d7855cd8309635d47e (
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
|
from pgcli.main import PGCli
from mock import Mock
DEFAULT = PGCli().row_limit
LIMIT = DEFAULT + 1000
over_default = Mock()
over_default.configure_mock(rowcount=DEFAULT + 10)
over_limit = Mock()
over_limit.configure_mock(rowcount=LIMIT + 10)
low_count = Mock()
low_count.configure_mock(rowcount=1)
def test_default_row_limit():
cli = PGCli()
stmt = "SELECT * FROM students"
result = cli._should_show_limit_prompt(stmt, low_count)
assert result is False
result = cli._should_show_limit_prompt(stmt, over_default)
assert result is True
def test_set_row_limit():
cli = PGCli(row_limit=LIMIT)
stmt = "SELECT * FROM students"
result = cli._should_show_limit_prompt(stmt, over_default)
assert result is False
result = cli._should_show_limit_prompt(stmt, over_limit)
assert result is True
def test_no_limit():
cli = PGCli(row_limit=0)
stmt = "SELECT * FROM students"
result = cli._should_show_limit_prompt(stmt, over_limit)
assert result is False
def test_row_limit_on_non_select():
cli = PGCli()
stmt = "UPDATE students set name='Boby'"
result = cli._should_show_limit_prompt(stmt, None)
assert result is False
cli = PGCli(row_limit=0)
result = cli._should_show_limit_prompt(stmt, over_default)
assert result is False
|