summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Rocco <drocco@gmail.com>2015-04-12 21:21:51 -0400
committerDaniel Rocco <drocco@gmail.com>2015-04-12 21:21:51 -0400
commit76b44443d1f738e16c3d05282f72317caeb463a5 (patch)
tree91f647a1391bf9d7c7a2aa7c78282a303bce3c50 /tests
parent4161f66ccaacc57b445f1a1add35c429de84c63a (diff)
Completion search text matches user-defined entities anywhere in the name
When searching for completions in smart completion mode, a potential suggestion of a user-specified name (e.g. tables, functions, etc.) is considered a match if the search text appears anywhere in the suggestion. Keywords, special commands, and built-in functions still use startswith matching. Closes #193
Diffstat (limited to 'tests')
-rw-r--r--tests/test_smart_completion_public_schema_only.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_smart_completion_public_schema_only.py b/tests/test_smart_completion_public_schema_only.py
index 13fa5c12..0c2d8972 100644
--- a/tests/test_smart_completion_public_schema_only.py
+++ b/tests/test_smart_completion_public_schema_only.py
@@ -89,6 +89,18 @@ def test_builtin_function_name_completion(completer, complete_event):
Document(text=text, cursor_position=position), complete_event)
assert set(result) == set([Completion(text='MAX', start_position=-2)])
+
+def test_builtin_function_matches_only_at_start(completer, complete_event):
+ text = 'SELECT IN'
+ position = len('SELECT IN')
+ document = Document(text=text, cursor_position=position)
+
+ result = [c.text for c in
+ completer.get_completions(document, complete_event)]
+
+ assert 'MIN' not in result
+
+
def test_user_function_name_completion(completer, complete_event):
text = 'SELECT cu'
position = len('SELECT cu')
@@ -98,6 +110,18 @@ def test_user_function_name_completion(completer, complete_event):
Completion(text='custom_func1', start_position=-2),
Completion(text='custom_func2', start_position=-2)])
+
+def test_user_function_name_completion_matches_anywhere(completer,
+ complete_event):
+ text = 'SELECT om'
+ position = len('SELECT om')
+ result = completer.get_completions(
+ Document(text=text, cursor_position=position), complete_event)
+ assert set(result) == set([
+ Completion(text='custom_func1', start_position=-2),
+ Completion(text='custom_func2', start_position=-2)])
+
+
def test_suggested_column_names_from_visible_table(completer, complete_event):
"""
Suggest column and function names when selecting from table