summaryrefslogtreecommitdiffstats
path: root/tests/test_smart_completion_multiple_schemata.py
diff options
context:
space:
mode:
authorJoakim Koljonen <koljonen@outlook.com>2017-03-04 02:08:47 +0100
committerJoakim Koljonen <koljonen@outlook.com>2017-03-05 02:21:31 +0100
commitbdf2a0e26adbe933c557ac6782511f7b1b9f9e01 (patch)
treefe2079faee92be1d8a31435e1ba483a36d7f1417 /tests/test_smart_completion_multiple_schemata.py
parent5514a4b67eb92f6e16c218fb887763a4f6bf1ae3 (diff)
Start suggesting tables/functions/views/types not in search_path
And schema-qualifying them, of course, so that for `SELECT * FROM bar` we might suggest `buildings.barns` and for `select dopi` we might suggest `maintenance.delete_old_personal_info()`, for example. Controlled by a config setting, `search_path_filter`, in case anyone prefers the old behaviour.
Diffstat (limited to 'tests/test_smart_completion_multiple_schemata.py')
-rw-r--r--tests/test_smart_completion_multiple_schemata.py76
1 files changed, 71 insertions, 5 deletions
diff --git a/tests/test_smart_completion_multiple_schemata.py b/tests/test_smart_completion_multiple_schemata.py
index 2d2d599a..f5a21b41 100644
--- a/tests/test_smart_completion_multiple_schemata.py
+++ b/tests/test_smart_completion_multiple_schemata.py
@@ -66,7 +66,7 @@ cased_schemas = [schema(x) for x in ('public', 'blog', 'CUSTOM', '"Custom"')]
@pytest.fixture
def completer():
- return testdata.completer
+ return testdata.get_completer(settings={'search_path_filter': True})
casing = ('SELECT', 'Orders', 'User_Emails', 'CUSTOM', 'Func1', 'Entries',
'Tags', 'EntryTags', 'EntAccLog',
@@ -74,15 +74,35 @@ casing = ('SELECT', 'Orders', 'User_Emails', 'CUSTOM', 'Func1', 'Entries',
@pytest.fixture
def completer_with_casing():
- return testdata.get_completer(casing=casing)
+ return testdata.get_completer(
+ settings={'search_path_filter': True},
+ casing=casing
+ )
@pytest.fixture
def completer_with_aliases():
- return testdata.get_completer({'generate_aliases': True})
+ return testdata.get_completer(
+ settings={'generate_aliases': True, 'search_path_filter': True}
+ )
+
+@pytest.fixture
+def completer_aliases_casing():
+ return testdata.get_completer(
+ settings={'generate_aliases': True, 'search_path_filter': True},
+ casing=casing
+ )
@pytest.fixture
-def completer_aliases_casing(request):
- return testdata.get_completer({'generate_aliases': True}, casing)
+def completer_all_schemas():
+ return testdata.get_completer()
+
+@pytest.fixture
+def completer_all_schemas_casing():
+ return testdata.get_completer(casing=casing)
+
+@pytest.fixture
+def completer_all_schemas_aliases():
+ return testdata.get_completer(settings={'generate_aliases': True})
@pytest.fixture
def complete_event():
@@ -598,3 +618,49 @@ def test_column_alias_search_qualified(completer_aliases_casing,
Document(text, cursor_position=len('SELECT E.ei')), complete_event)
cols = ('EntryID', 'EntryTitle')
assert result[:3] == [column(c, -2) for c in cols]
+
+def test_all_schema_objects(completer_all_schemas, complete_event):
+ text = 'SELECT * FROM '
+ position = len('SELECT * FROM ')
+ result = set(
+ completer_all_schemas.get_completions(
+ Document(text=text, cursor_position=position),
+ complete_event
+ )
+ )
+ assert result >= set(
+ [table(x) for x in ('orders', '"select"', 'custom.shipments')]
+ + [function(x+'()') for x in ('func2', 'custom.func3')]
+ )
+
+def test_all_schema_objects_with_casing(
+ completer_all_schemas_casing, complete_event
+):
+ text = 'SELECT * FROM '
+ position = len('SELECT * FROM ')
+ result = set(
+ completer_all_schemas_casing.get_completions(
+ Document(text=text, cursor_position=position),
+ complete_event
+ )
+ )
+ assert result >= set(
+ [table(x) for x in ('Orders', '"select"', 'CUSTOM.shipments')]
+ + [function(x+'()') for x in ('func2', 'CUSTOM.func3')]
+ )
+
+def test_all_schema_objects_with_aliases(
+ completer_all_schemas_aliases, complete_event
+):
+ text = 'SELECT * FROM '
+ position = len('SELECT * FROM ')
+ result = set(
+ completer_all_schemas_aliases.get_completions(
+ Document(text=text, cursor_position=position),
+ complete_event
+ )
+ )
+ assert result >= set(
+ [table(x) for x in ('orders o', '"select" s', 'custom.shipments s')]
+ + [function(x) for x in ('func2() f', 'custom.func3() f')]
+ )