11from mssqlcli .main import MssqlCli
2- from mock import Mock
32
43DEFAULT = MssqlCli ().row_limit
54LIMIT = DEFAULT + 1000
65
7-
8- over_default = Mock ()
9- over_default .configure_mock (rowcount = DEFAULT + 10 )
10-
11- over_limit = Mock ()
12- over_limit .configure_mock (rowcount = LIMIT + 10 )
13-
14- low_count = Mock ()
15- low_count .configure_mock (rowcount = 1 )
16-
6+ low_count = 1
7+ over_default = DEFAULT + 1
8+ over_limit = LIMIT + 1
179
1810def test_default_row_limit ():
1911 cli = MssqlCli ()
2012 stmt = "SELECT * FROM students"
21- result = cli ._should_show_limit_prompt (stmt , low_count )
13+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * low_count )
2214 assert result is False
2315
24- result = cli ._should_show_limit_prompt (stmt , over_default )
16+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * over_default )
2517 assert result is True
2618
2719
2820def test_set_row_limit ():
2921 cli = MssqlCli (row_limit = LIMIT )
3022 stmt = "SELECT * FROM students"
31- result = cli ._should_show_limit_prompt (stmt , over_default )
23+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * over_default )
3224 assert result is False
3325
34- result = cli ._should_show_limit_prompt (stmt , over_limit )
26+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * over_limit )
3527 assert result is True
3628
3729
3830def test_no_limit ():
3931 cli = MssqlCli (row_limit = 0 )
4032 stmt = "SELECT * FROM students"
4133
42- result = cli ._should_show_limit_prompt (stmt , over_limit )
34+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * over_limit )
4335 assert result is False
4436
4537
@@ -50,5 +42,5 @@ def test_row_limit_on_non_select():
5042 assert result is False
5143
5244 cli = MssqlCli (row_limit = 0 )
53- result = cli ._should_show_limit_prompt (stmt , over_default )
45+ result = cli ._should_show_limit_prompt (stmt , [ 'row' ] * over_default )
5446 assert result is False
0 commit comments