diff options
author | Irina Truong <i.chernyavska@gmail.com> | 2019-08-23 13:44:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-23 13:44:36 -0700 |
commit | b2ebe0e95c6b9f28574804d5f1ea8d689ccd5211 (patch) | |
tree | ddf03d549938ca254ec9fdd69661df2141fa0edc /tests/test_rowlimit.py | |
parent | 19c3e0eeb81f4a231d0ebfd2c18c47215f85e572 (diff) |
Issue 1018 display first 1k rows (#1092)
* Added changes to remove the prompt on >1000 rows queries
* Reformatted with black
* Changed comment on row_limit parameter
* Added contribution to changelog and name to AUTHORS
* Refactored test to reflect new functionality
* Removed argument
* Removed debug echo statement
* Reformatted with black
* Added changes to remove the prompt on >1000 rows queries
* Reformatted with black
* Changed comment on row_limit parameter
* Added contribution to changelog and name to AUTHORS
* Refactored test to reflect new functionality
* Removed argument
* Removed debug echo statement
* Reformatted with black
* Added missing issue numbers in changelog
* Reformatted code using black
Diffstat (limited to 'tests/test_rowlimit.py')
-rw-r--r-- | tests/test_rowlimit.py | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/test_rowlimit.py b/tests/test_rowlimit.py index bc66f1e7..e76ea049 100644 --- a/tests/test_rowlimit.py +++ b/tests/test_rowlimit.py @@ -1,6 +1,7 @@ -from pgcli.main import PGCli -from mock import Mock import pytest +from mock import Mock + +from pgcli.main import PGCli # We need this fixtures beacause we need PGCli object to be created @@ -43,40 +44,36 @@ def low_count(): return low_count_cursor -def test_default_row_limit(low_count, over_default): - cli = PGCli() - stmt = "SELECT * FROM students" - result = cli._should_show_limit_prompt(stmt, low_count) +def test_row_limit_with_LIMIT_clause(LIMIT, over_limit): + cli = PGCli(row_limit=LIMIT) + stmt = "SELECT * FROM students LIMIT 1000" + + result = cli._should_limit_output(stmt, over_limit) assert result is False - result = cli._should_show_limit_prompt(stmt, over_default) - assert result is True + cli = PGCli(row_limit=0) + result = cli._should_limit_output(stmt, over_limit) + assert result is False -def test_set_row_limit(over_default, over_limit, LIMIT): +def test_row_limit_without_LIMIT_clause(LIMIT, over_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) + result = cli._should_limit_output(stmt, over_limit) assert result is True - -def test_no_limit(over_limit): cli = PGCli(row_limit=0) - stmt = "SELECT * FROM students" - - result = cli._should_show_limit_prompt(stmt, over_limit) + result = cli._should_limit_output(stmt, over_limit) assert result is False -def test_row_limit_on_non_select(over_default): +def test_row_limit_on_non_select(over_limit): cli = PGCli() - stmt = "UPDATE students set name='Boby'" - result = cli._should_show_limit_prompt(stmt, None) + stmt = "UPDATE students SET name='Boby'" + result = cli._should_limit_output(stmt, over_limit) assert result is False cli = PGCli(row_limit=0) - result = cli._should_show_limit_prompt(stmt, over_default) + result = cli._should_limit_output(stmt, over_limit) assert result is False |